I have an external USB drive, formatted in Mac OS Extended (Journaled) which I use with my iBook G4 (OS X Tiger).

Sometimes when I eject the drive the computer hangs and the pinwheel spins for a few minutes, and everything is fine.  Other times it’s not.  I’m not sure if firewire drives perform any better.  I bought the USB drive because it was small and cheap.

Anyways, one day I plugged the drive in and OS X couldn’t mount it.  I tried repairing it in Disk Utility and the repair failed with an “Invalid Volume Header“.  DiskWarrior is supposed to be able to repair drives that Disk Utility can’t, but I didn’t feel like spending the $100.  All of the photos on this drive were mirrored on another drive and also on DVD.  The only thing I’d be losing are the star ratings I’d assigned to the photos (for the process of sorting through them).

So, considering that I wasn’t about to lose any data that I didn’t already have backed up, I tried to find a UNIX-type way to repair the disk.  The Apple website had some notes about fsck (file system check), but nothing much that helped me.  Then I found a website (that I can no longer find) that provided a solution running fsck.

First, start up disk utility and write down the location of the disk that won’t mount.  OS X will give it a location such as /dev/disk1s3 .  See Figure 1.

disk that won't mount

If you run disk utility you will get an error message such as shown in Figure 2.

disk utilities fails

The way to repair the disk is to use fsck with the -r and -f flags. -r rebuilds the filesystem catalog, and some times you’ll need to use the -f flag to force a check because it’s a journaled system.  I haven’t had to use the -f flag (perhaps someone could comment on this?). If your drive is given the location /dev/disk1s3 you would type:

fsck_hfs -r /dev/disk1s3

Terminal will take a few minutes then spit out a bunch of code like this:
josh:~ Josh$ fsck_hfs -r /dev/disk1s3
** /dev/rdisk1s3
Invalid Volume Header
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Rebuilding Catalog B-tree.
** Rechecking volume.
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
Missing thread record (id = 485454)
Incorrect number of thread records
(4, 226)
Incorrect number of thread records
(4, 226)
** Checking multi-linked files.
** Checking Catalog hierarchy.
Missing thread record (id = 485454)
Invalid directory item count
(It should be 38 instead of 57)
Missing thread record (id = 485441)
Invalid directory item count
(It should be 0 instead of 3)
Invalid volume file count
(It should be 402470 instead of 404177)
** Checking Extended Attributes file.
** Checking volume bitmap.
Volume Bit Map needs minor repair
** Checking volume information.
Invalid volume free block count
(It should be 9243234 instead of 13012437)
Volume Header needs minor repair
(2, 0)
** Repairing volume.
** Rechecking volume.
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
Missing thread record (id = 471381)
Missing thread record (id = 473603)
Missing thread record (id = 476491)
Incorrect number of thread records
(4, 226)
** Checking multi-linked files.
** Checking Catalog hierarchy.
Invalid volume file count
(It should be 402470 instead of 404177)
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
** Repairing volume.
Missing directory record (id = 476491)
Missing directory record (id = 473603)
Missing directory record (id = 471381)
** Look for missing items in lost+found directory.
** Rechecking volume.
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking multi-linked files.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
Invalid volume file count
(It should be 404177 instead of 402470)
** The volume HDD could not be repaired after 3 attempts.

If it still reports a failure, run it again.

josh:~ Josh$ fsck_hfs -r /dev/disk1s3
** /dev/rdisk1s3
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Rebuilding Catalog B-tree.
** Rechecking volume.
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking multi-linked files.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
Invalid volume file count
(It should be 404177 instead of 402470)
** Repairing volume.
** Rechecking volume.
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking multi-linked files.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume HDD was repaired successfully.
josh:~ Josh$

Success!  The volume is repaired.

Apple reports that some errors that get reported when a volume is journaled are benign. See http://support.apple.com/kb/TS2028?viewlocale=en_US. See also http://support.apple.com/kb/TA21053?viewlocale=en_US for Apple’s support page on repairing a journaled volume.

Advertisements