How to verify and repair your hard disk in OS X

DiskUtilityIconXHard disk maintenance is one of the few regular maintenance routines that I recommend people do for their Macs. Your hard drive’s formatting is the structure used by the system to store and retrieve every file saved to the drive. In most Mac systems, the boot drive will be using Apple’s Mac OS Extended (HFS+) filesystem format, which is a collection of fast-access “B-tree” databases that store where a file is located on your drive, its logical hierarchical organization, and attributes such as file ownership and access permissions.

If damage occurs to your filesystem structure, then data-access problems can occur, leading to slowdowns, hangs, or crashes. In more severe cases, filesystem corruption can result in continual data corruption, meaning that data written to the drive can be irrecoverably damaged.

In many cases, corruption to the filesystem can start as a small issue, but then grow as additional damage occurs or perpetuates from the original corruption. Therefore, it is best to regularly ensure the filesystem on your Mac is healthy, especially if you have ever lost power or had to force-restart your Mac.

For the routines below, keep in mind that you can only verify the boot volume, and will not be able to repair it. To do this, you will have to boot to Recovery Mode () or to another partition other than your boot volume.

Disk Utility

Disk Utility in OS X

With your drives selected in Disk Utility, clicking Verify Disk will check them for errors. Note the Repair option will be available for all drives except for the boot drive.

The first option for checking the hard drive is Apple’s Disk Utility program, located in the Applications > Utilities folder. To use this, follow these steps:

  1. Open Disk Utility
  2. Select your desired drive in the sidebar
  3. Go to the “First Aid” tab (it should be the default one)
  4. Click the Verify Disk button

Note that in step 2 above, you can select multiple drives (or all of them) to verify or repair them all at once. To do this, hold the Command key to add or remove additional drives to the selection by clicking them, or press Command-A to select all drives in the list.

Terminal

While Disk Utility is the most intuitive approach for checking your drive, you can also do so in the OS X Terminal using either the “diskutil” command, in the following manner:

1. Open the Terminal and run the following command:

diskutil list

In the output, find the name of your volume in the NAME column, and then note its identity in the IDENTIFIER column (this will be something like “disk0″ or “disk1″—do not worry about the “s1″ or “s2″ components of the identifier).

2. Now run the following command using the proper identifier to check the drive’s partition scheme, replacing “DRIVEID” with that you determined from the command above:

diskutil verifyDisk DRIVEID

3. Next, run the following command using the proper volume name determined above in place of “VOLUMENAME”

diskutil verifyVolume VOLUMENAME

Note that if the volume name has spaces in it, then you will either need to encase the name in quotes, or use a back-slash to escape the space character, such as the following:

diskutil verifyVolume “Macintosh HD”
diskutil verifyVolume Macintosh\ HD

If your volume name has odd characters in it (such as emoji) that cause problems when typed in the Terminal, then you can specify the volume using the full identifier (using the “s1″ or “s2″ that were disregarded above), or if you are trying to target the boot drive only, then you can use a single forward slash to specify the root device:

diskutil verifyVolume disk0s2
diskutil verifyVolume /

Single-User mode

In addition to diskutil, OS X includes the “fsck” command, which similarly can check and repair your drive. This command is available if you boot to Singe-User mode in OS X by holding the Command-S keys at startup. The differences when running this command are that you will need to specify the disk file by its full path (in the /dev directory), such as the following examples.

sudo fsck_hfs -f /dev/disk0s2
sudo f sck_hfs -fy /dev/disk0s2

Preventing Corruption

Even though with added features like Journaling, Apple’s HFS+ filesystem is fairly stable, it can still become corrupted in the event you experience a power outage, or have to force-restart your system (especially during boot-up, or otherwise when the disk is being actively read and written to). Therefore, to help prevent filesystem corruption, avoid holding the power button to force-restart your system as much as possible.

For external drives you use with your system, be sure to properly eject them before unplugging them. If the drives sometimes unmount unexpectedly, then try rearranging how they are attached to your system, replace cables, and avoid daisy-chaining them together. In addition, be sure to use an external power supply for the drive, if one was provided by the manufacturer.

3 thoughts on “How to verify and repair your hard disk in OS X

  1. Pingback: prix sac louis vuitton

  2. Pingback: How to fix deep formatting problems with OS X drives | MacIssues

Leave a Reply to MaX Cancel reply