Saturday, July 04, 2026

FSCK an HFS+ disk in Ubuntu Linux

I was trying to create a disk image of my 13" MacBook, after its ill timed death, in Clonezilla with the hope that I could reuse my Sandisk SSD for other high speed data storage purposes. Unfortunately, the ill timed death means the volume was not unmounted cleanly which results in Linux HFS driver loading the disk in read only mode. Clonezilla, based on Ubuntu, will refuse to close a drive that reports that its not clean. Unfortunately, I don't have a Mac with which I can run diskutils so I need to compile it myself. Here is how to do it. This was testing on Ubuntu 13.04 (Saucy) but should work well on any other system.

sudo apt-get update && sudo apt-get install build-essential
mkdir ~/hfs.util && cd ~/hfs.util
wget http://www.opensource.apple.com/tarballs/diskdev_cmds/diskdev_cmds-332.14.tar.gz && wget http://pkgs.fedoraproject.org/repo/pkgs/hfsplus-tools/diskdev_cmds-332.14.patch.bz2/e488b401bec3d5b6884afe4e2a8086e3/diskdev_cmds-332.14.patch.bz2
tar zxf diskdev_cmds-332.14.tar.gz
bunzip2 -c diskdev_cmds-332.14.patch.bz2 | patch -p0
cd diskdev_cmds-332.14
make -f Makefile.lnx
sudo cp fsck_hfs.tproj/fsck_hfs /usr/local/sbin/fsck.hfsplus

Congrats, you now have fsck for HFS+ volumes on Linux!

Now to repair your drive.

Find your drive and ensure that its not mounted. In my case, it was /dev/sdb2


No comments: