Sunday, March 2, 2014

Mac OS X - fix boot problem due to hard disk errors

Returning from a 2 week trip to the Singapore and Myanmar (aka Burma), my Mac Book Pro 13 which had sat at home powered off the whole time, refused to boot.  About 15% throught the progress bar when booting, the Mac would power off.

Looking up keyboard shortcuts, I held down the 'd' key to show diagnostics, which indicated the mac was failing during the automatic fsck (disk drive file system check).

The solution:

  1. Boot to single user, by holding the 's' key once the startup gong sounds.
  2. Try /sbin/fsck -fy which forces a fix answering "yes" to all questions.  Repeat this command until no errors are reported.
  3. In my case, the "catalog" tree structure was broken enough that fsck stopped without fixing the problem.
  4. I ran fsck_hfs directly which has additional options not supported by the generic fsck, shown by man fsck_hfs.  In the following command, I used the raw device (/dev/rdisk0s2, for my laptop, yours maybe different) for my hard drive that the previous fsck had shown in step 2:
       /sbin/fsck_hfs -Rc /dev/rdisk0s2After this I reran /sbin/fsck -fy to verify the disk had been reconstructed.
  5. Restart the computer by exiting out of single user mode:  exit