While rare, in OS X you may run across a problem where upon copying or accessing files and folders, the system will stop and display an warning that simply states the operation could not be completed because of an error. For the most part when this occurs, you will see error code -36 displayed, but it can also include other numbers. If these happen, there may be a quick fix you can try, but generally they indicate unknown low level problems with your Mac.
If you run into this error, first check whether or not it occurs randomly, or only when you attempt to manage specific files, especially files that you might have had around for a long time as you migrated through different Macs and upgraded them to newer versions of OS X. The HFS+ filesystem format that Apple uses for OS X supports two modes of saving data for files: a data fork, and a resource fork. Classically these had specific purposes, and while both can technically be accessed, in OS X Apple gave up the use of the resource fork and almost exclusively uses the data fork for file. However, support for the resource fork still exists and some files use them.
If this is the case, then the errors you experience will only show up at specific times, such as when attempting to copy a certain file or folder. To fix this, you can use a tool in OS X to merge and otherwise manage these hidden “._” files (aka “AppleDouble” or “dot-underscore” files):
- Open the OS X Terminal.
- Type “dot_clean -n” followed by a single space.
- Drag the specific file or folder to the Terminal window and press Enter.
When doing this, the system will attempt to merge the file you specify with any hidden “._” file that may correspond to it. If you do so for a directory, then the system will attempt this for all files in the directory and remove any “._” file that cannot be matched and merged with a native file. As a result, you can attempt this process on collections of files by passing their parent directory to the command instead of nit-picking around specific files.
If you still experience these errors after attempting this process on a few files, then your next bet is to try the process on your entire filesystem. First make sure you have a full and restorable backup of your disk using Time Machine and then run the following command in the OS X Terminal (supply your password when prompted–it will not show):
sudo dot_clean -n /
Note that the slash points to the top level of your boot drive, and you can specify secondary drives by deleting the slash and then dragging the desired volume to the Terminal to input the full path to the drive’s location.
Other formatting errors
After completing this, again if the errors occur then the problem is likely not with the management of dot-underscore files on your filesystem, and suggest a lower-level problem is at hand. At this point, try using Apple’s Disk Utility program to check your filesystem for errors:
- Open Disk Utility.
- Select your drive’s volume.
- Click the First Aid tab.
- Click “Verify Disk.”
If any errors show up, then click the Repair button to attempt a fix on them. This button will be unavailable for your boot drive, so reboot your Mac and hold the Command-R keys to load Recovery mode, and then open Disk Utility there to run a repair routine on your boot volume.
Another approach here is to attempt filesystem repairs with the filesystem repair tool DiskWarrior, which has very robust options for rebuilding and repairing damaged OS X filesystems and may be able to overcome such problems; however, this and similar tools are not free and there is no guarantee they will work, especially since general errors such as this may occur from hardware problems. As a result, provided you have a full backup of your system, consider wiping your drive and setting up its filesystem from scratch:
- Reboot your Mac to Recovery Mode.
- Open Disk Utility, select your drive, and erase it using the options in the Erase tab.
- Quit Disk Utility.
- Use the backup recovery utility to restore your recent backup.
Granted restoring from backup should re-format your drive, but doing so with Disk Utility ensures it is done. After your backups are restored, keep in mind that even if the problem does not immediately re-surface, it may still be present if your drive is failing. Therefore, be sure to periodically check your drive for errors using Disk Utility, and be aware of any problems such as repeated hangs or sudden exceptionally slow processes like a newly launched program bouncing forever in the Dock.
If these behaviors happen, then open the OS X Console utility (in Applications > Utilities), select the “All Messages” section, and then perform a search for the term “kernel.” This will isolate messages to those coming from the core OS X system software that is responsible for hardware management, so if there is a problem then you should see relevant output instead of a flurry of benign informational messages from other software and services running on your Mac.
At this point, you are primarily looking for the term “I/O Errors” that occur around the same time that your system hangs. If these appear at all, then it suggests your drive is failing either from controller malfunction, or failing storage media. In these cases, salvaging the drive is likely useless as these errors will continue to propagate until the drive cannot be used, so your best best is to immediately make redundant full-system backups and then take your Mac into a service center to have its hard drive replaced (for external drives, you can simply buy a new replacement).