BrT

Musings about technology and other neat stuff

BrT random header image

Fixing a corrupt HFS+ filesystem in Linux (HOWTO)

June 4th, 2006 · 1 Comment

Some time ago I switched my server (a G4 Mac) from MacOSX to Gentoo Linux. In the process, the secondary internal disk (where I keep the mail storage, among other things) remained formatted as HFS+, because it made the transition easier. However, I kept having problems with it. For example, if the machine shut down uncleanly, it would mount only in read-only mode, and special trickery was needed to restore it (if you are interested: mount the device using hpmount from the hfsplusutils package, then run hpumount, and then you can mount it r/w again).

Today, I noticed the 80GB disk was reporting only 3GB free, but I had only about 30GB of stuff in it – where was the missing space gone? In a fit of imprudence, I unmounted it and ran hfsck (from hfsutils, instead of hpfsck from hfsplusutils) on it, which completely hosed it, because it modified its filesystem type, so hpmount and hpfsck refused to even touch it. Looking desperately around, I finally found the solution in the omniscient Gentoo Wiki: http://gentoo-wiki.com/HOWTO_hfsplus.

In particular, this page describes how to compile the fsck.hfsplus command from Darwin in Linux. Hoping for the best, I compiled it and ran it (I used the “Newer x86/PPC Linux port from OS X 10.4.3 / Darwin 8.3″ version). The first time it complained the FS could not be repaired, but on subsequent runs it was successful, and I finally could get my filesystem back.

I have now backed up the partition, redid it as a ReiserFS partition, and I’m getting rid of HFS+ forever on this machine. About time.

Technorati Tags: , ,

Tags: · ·

1 response so far ↓

  • 1  OJ // Feb 6, 2008 at 9:23 am

    In case anyone else has this problem, by having run hfsck on a hfs+ filesystem, then you will find that fsck.hfsplus does not work. The solution is to use hpmount (even though it will not mount, giving errors), and then running fsck.hfsplus after it. This for some reason triggers it to repair.