Weblog entry #21 for lee

fscking HFS+
Posted by lee on Fri 8 Sep 2006 at 13:55
Tags: none.

fscking hfsplus in both senses!

I have a 1TB Lacie disk attached to a PC running Ubuntu at work. It needs to be readable and writable under both Linux and OSX so I assumed that leaving it as HFS+ would be OK. The disk automounted under Gnome and had been running fine until it got removed without being unmounted. After that, dragging files to it via Nautilus resulted in the following warning:

  Error while copying to "/media/archive".
  You do not have permissions to write to this folder

The permissions look fine, so I try from the command line.

$ touch /media/archive/test
touch: cannot touch `/media/archive/test': Read-only file system
$ mount | grep /media/archive
  /dev/sdg6 on /media/archive type hfsplus (rw,nosuid,nodev,uid=1000,gid=1000)

OK, apparently mount is lying about the disk being mounted read-write?

  HFS+-fs warning: Filesystem was not cleanly unmounted, running fsck.hfsplus is recommended.  mounting read-only.

I "eject" the disk from Gnome and run "fsck.hfsplus /dev/sdg6".

Well... I would. mkfs.hfsplus isn't installed and doesn't appear to be available in Ubuntu. There is a package, hfsplus, which contains "hpfsck" so I give that a try.

# hpfsck /dev/sdg6
*** Checking Volume Header:
Volume was not cleanly unmounted
Volume is inconsistent
                                                Done ***
*** Checking Backup Volume Header:
Volume is inconsistent
Volume was last Mounted by unknnown implemenatation:
kcsf                                            Done ***
*** Checking Extents Btree:
checkbtree_key_by_index: offset out of range E00 >= 400
                                *** Check stopped ***
hpfsck: hpfsck: no error (Success)

No change.

Checking search engines, I see that many Linux iPod users have this issue. However the fix usually involves reformatting to FAT32, something I'm not willing to do. Digging deeper, it seems that the hfsplus is out-of-date, unmaintained, and known not to work. Apparently the only tools that work with HFS+ are the disk tools ported from Darwin. They don't seem to have been packaged for debian (Sadly, the developer that opened the ITP, Bug#229769, later died in an accident) or Ubuntu, but I found some manual installation instructions on a Gentoo wiki.

wget http://darwinsource.opendarwin.org/tarballs/apsl/diskdev_cmds-332.14.tar.gz
wget http://www.ecl.udel.edu/~mcgee/diskdev_cmds/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
(yes, fsck programs shouldn't usually go anywhere except /sbin)
# fsck.hfsplus /dev/sdg6
** /dev/sdg6
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking Catalog hierarchy.
** Checking volume bitmap.
** Checking volume information.
** The volume archive appears to be OK.

Resetting the device and allowing it to automount now allows writing. Hurrah.

 

Comments on this Entry

Posted by Anonymous (24.91.xx.xx) on Mon 9 Oct 2006 at 09:24
YES!! This worked great! Running the same commands with OSX AND Linux got me the same result for my external FW drive. It's nice to know I can compile things from darwin on my debian ppc powerbook, though! Luckily, I can get read access, and do some backing up before I wipe and reformat my drive.

Thanks, keep up the great work!!

[ Parent | Reply to this comment ]

Posted by Anonymous (130.232.xx.xx) on Sat 2 Dec 2006 at 15:11
Oh, sweet. Thanks a bunch!

[ Parent | Reply to this comment ]

Posted by Anonymous (69.137.xx.xx) on Fri 30 Mar 2007 at 17:51
Any ideas how to get this working on Ubuntu FeistyFawn?

[ Parent | Reply to this comment ]

Posted by lee (193.82.xx.xx) on Mon 2 Apr 2007 at 10:47
[ Send Message | View Weblogs ]
This should work on any Ubuntu release (I've just tested, and it does build on Feisty). Do you have the necessary development packages installed?
apt-get install build-essential

[ Parent | Reply to this comment ]

Posted by Anonymous (89.217.xx.xx) on Tue 22 May 2007 at 23:20
Hello, since opendarwin shutted down, I cannot find the tarballs needed to compile fsck.hfsplus. Does anybody has a copy or knows a mirror still active?

you can contact me at ciampagg- a t -lu.unisi.ch
|Giovanni

[ Parent | Reply to this comment ]

Posted by Anonymous (89.217.xx.xx) on Tue 22 May 2007 at 23:23
ok found them just googling! :)

[ Parent | Reply to this comment ]

Posted by Anonymous (78.86.xx.xx) on Mon 24 Dec 2007 at 09:07
The link to the patchfile you´ve used it not valid anymore, i´ve used this one, worked for me.

ftp://ftp.fi.debian.org/pub/gentoo/distfiles/diskdev_cmds-332.14. patch.bz2


sven

[ Parent | Reply to this comment ]

Posted by Anonymous (189.5.xx.xx) on Thu 17 Jul 2008 at 22:17
I have a iBook G4 with dual-boot Mac OS 10.3 and Debian and I was trying to share my /home directory in between the two systems, following this excelent how-to (http://pierre.baudu.in/ibook/).

But I couldn't get the HFS+ partition to be mounted on Debian, so I tried to follow the instructions above, but when passing the command "bunzip2 -c diskdev_cmds-332.14.patch.bz2 | patch -p0" something strange appears to happen.

I've tried a couple of times, but I always get the same problem (asking me for a file to be patched...)

This is the message I get from the Terminal:



[quote]

debian:/home/fabiopanico# bunzip2 -c diskdev_cmds-332.14.patch.bz2 | patch -p0
patching file diskdev_cmds-332.14/Makefile.lnx
patching file diskdev_cmds-332.14/diskdev_cmds-332.11/Makefile.lnx
patching file diskdev_cmds-332.14/diskdev_cmds-332.11/fsck_hfs.tproj/Makefile.l nx
patching file diskdev_cmds-332.14/fsck_hfs.tproj/Makefile.lnx
can't find file to patch at input line 66
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -Naur diskdev_cmds-332.14/fsck_hfs.tproj/cache.c diskdev_cmds-332.14.patched/fsck_hfs.tproj/cache.c
|--- diskdev_cmds-332.14/fsck_hfs.tproj/cache.c 2006-02-20 16:45:15.000000000 -0500
|+++ diskdev_cmds-332.14.patched/fsck_hfs.tproj/cache.c 2006-11-12 22:53:09.000000000 -0500
--------------------------
File to patch:

[/quote]



Does anyone know what I'm doing wrong? How can I get it to work?

Thank you very much,

Fabio > fabiopanico (at) gmail.com

[ Parent | Reply to this comment ]

Posted by Anonymous (41.232.xx.xx) on Thu 4 Mar 2010 at 08:13
good post thank you very much
<a href=”http://www.helmenaa.com/vb/forumdisplay.php?f=74”>winnin g eleven patches</a>

[ Parent | Reply to this comment ]