mounting large (> 2TB) hfsplus (mac) partitions on linux / ubuntu

I recently wanted to read an external drive which I’d formatted under Mac OS with Linux. Unfortunately, it was > 2TB, which seems to not be supported under Linux. It appears as if many of the vulnerabilities which used to exist (use of 32-bit values instead of 64-bit ones) seems to have been fixed, but the kernel still refuses to allow mounting.  I figured out how to patch the kernel module to allow me to mount > 2TB partitions.

Important: I only intended to mount the partitions read-only, so I didn’t go through the code carefully to ensure that it won’t corrupt your data if you try to write to it! Use this at your own risk!!

  1. Using Ubuntu 11.04, upgrade to the latest kernel
  2. root@mysterion:~# apt-get install linux-image-2.6.38-8-generic && apt-get install linux-headers-2.6.38-8-generic &&
    apt-get install linux-source-2.6.38 && reboot

  3. Next, unzip the source

  4. root@mysterion:~# cd /usr/src/linux-source-2.6.38
    root@mysterion:/usr/src/linux-source-2.6.38# tar xfvp linux-source-2.6.38.tar.bz2

  5. Next, patch the errant file; comment out the “goto out” code so it looks like this:

  6. root@mysterion:/usr/src/linux-source-2.6.38# grep -A 3 supported linux-source-2.6.38/fs/hfsplus/wrapper.c
    pr_err("hfs: volumes larger than 2TB are not supported yet\n");
    //goto out;
    }

  7. Next, copy some files needed to build the module, and fix up the makefile:



  8. root@mysterion:/usr/src/linux-source-2.6.38/linux-source-2.6.38# kernver=$(uname -r)
    root@mysterion:/usr/src/linux-source-2.6.38/linux-source-2.6.38# kernextraver=$(echo $kernver | sed "s/$kernbase\(.*\)/\1/")
    root@mysterion:/usr/src/linux-source-2.6.38/linux-source-2.6.38# sed -i "s/EXTRAVERSION = .*/EXTRAVERSION = $kernextraver/" Makefile
    root@mysterion:/usr/src/linux-source-2.6.38/linux-source-2.6.38# cp /usr/src/linux-headers-2.6.38-8-generic/Module.symvers .
    root@mysterion:/usr/src/linux-source-2.6.38/linux-source-2.6.38# cp /boot/config-2.6.38-8-generic .
    root@mysterion:/usr/src/linux-source-2.6.38# make oldconfig && make prepare && make modules_prepare && make SUBDIRS=fs/hfsplus/ modules

  9. at this point, you should be able to run
    insmod fs/hfsplus/hfsplus.ko
    and then mount your hfsplus partition, using -oforce . please also use -oro for now.

Posted

in

by

Tags:

Comments

2 responses to “mounting large (> 2TB) hfsplus (mac) partitions on linux / ubuntu”

  1. tom Avatar
    tom

    did not really work for me 🙁 (kernel 3.0.0)

  2. tom Avatar
    tom

    oh, i had to reboot 😀 seems to work now.

Leave a Reply

Your email address will not be published. Required fields are marked *