14

I have a problem mounting some hfsplus drives. I just need them mounted readonly. (disabling journal is not an option) I did a lot of research and found out that due to changes from kernel version 2.6.37 to 2.6.38 the problem started.

Have a look at this link at bugs.launchpad.net.

So I tested it with Linux kernel version 2.6.37 and lower and it worked fine as it should.

Versions above including my version which is 3.2.0-54-generic(ubuntu 12.04) did not work fine with mounting hfsplus images and disks. So I need the hfsplus module from a working version like 2.6.31-14-generic from ubuntu 9.

I use these commands in this case with a HFS+ DD image. But I did this with other hfsplus physical drives and other images. They all work with kernel 2.6.37 and lower but not with newer versions:

sudo losetup -d /dev/loop0
sudo losetup /dev/loop0 -o $((512*409640)) /folder/iMac_21.dd

sudo mount -t hfsplus /dev/loop0 /mnt/hfs
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error

dmesg | tail
[84980.380254] hfs: invalid secondary volume header

I have to add this information to "proof" that the problem is after kernel 2.6.38. Have a look at this. That is a NTFS und HFS+ driver from Paragon.

"What's new in Paragon NTFS & HFS+ for Linux 8.5:
Support for modern Linux Kernels (up to 2.6.38);"
paragon-software.com/home/ntfs-linux-per/features.html

To fix the problem I just copied /lib/modules/2.6.27/kernel/fs/hfsplus.ko to my current 3.2.0-54-generic kernel. But that did not work. How do I get the working hfsplus part into my current 3.2.0-54-generic kernel ubuntu 12.04 linux? Or how to fix my kernel to work just like in 2.6.37 ?

The best hint I did see was this one.

3 Answers 3

19

This question is a bit old but I came across it while trying to mount an HFS+ partition in the same circumstances, and found the solution. I'm not quite sure how it is related to kernel version, mine is 3.13 (3.13.7-1 x86_64, Debian).

Short answer

Provide the size of the partition as well as its offset.

Long answer

First get the partition's information from Parted, in bytes; you need the Start and the Size numbers. Here is an example of Parted session (as you can guess, my hard drive image is /mnt/macbook.dd):

$ /sbin/parted /mnt/macbook.dd
WARNING: You are not superuser.  Watch out for permissions.
GNU Parted 2.3
Using /mnt/macbook.dd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit
Unit?  [compact]? b
(parted) p
Model:  (file)
Disk /mnt/macbook.dd: 160041885696B
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start       End            Size           File system  Name                  Flags
 1      20480B      209735679B     209715200B     fat32        EFI system partition  boot
 2      209735680B  159907647487B  159697911808B  hfs+         Customer

If I try to mount the partition by providing only the offset (start), I get the same error as you:

# mount -v -t hfsplus -o ro,loop,offset=209735680 /mnt/macbook.dd /media/mac
mount: enabling autoclear loopdev flag
mount: going to use the loop device /dev/loop0
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
# dmesg | tail -n2
[117791.463123] hfsplus: invalid secondary volume header
[117791.463132] hfsplus: unable to find HFS+ superblock

By the way, you don't need to use losetup, mount does that for you automatically. Now if I add the partition's size (sizelimit), it works perfectly:

# mount -v -t hfsplus -o ro,loop,offset=209735680,sizelimit=159697911808 /mnt/macbook.dd /media/mac
mount: enabling autoclear loopdev flag
mount: going to use the loop device /dev/loop0
/mnt/macbook.dd on /media/mac type hfsplus (ro,offset=209735680,sizelimit=159697911808)
3
  • 6
    your solution takes care of the "invalid secondary volume header" message for me, but the "unable to find HFS+ superblock" error persists :( May 29, 2015 at 16:12
  • 2
    Still getting both errors in dmesg even though I specified both offset and sizelimit
    – wkarl
    Sep 17, 2015 at 23:32
  • not clear what the offset should be -- for me, the Number of my device is 1, and offset=1 and offset=0 both fail Oct 31, 2017 at 7:53
18

For anyone else stumbling upon this question while looking for the same error message, note that there is another possible cause for this error.

While the answer provided by mcy should work if the partition is actually an HFS+ partition, starting with OSX Yosemite the default partition type for a Mac is "Core Storage", which is used to handle logical volumes. This means that what you actually want to mount is a logical volume (using HFS+ filesytem) inside the "Core Storage" partition.

To see if your partition is of type "Apple Core Storage" you can use gdisk: AF05 is the code for "Apple Core Storage", while af00 is the code for "Apple HFS/HFS+".

If your disk uses "Apple Core Storage", you can use the guide provided in this answer to mount it.

1
  • 1
    Thank you! This was exactly the issue I was facing. Linked solution works well. Aug 30, 2016 at 14:58
0

The two answers listed here did not help me. Instead, I installed hfsprogs:

$ sudo apt-get install hfsprogs 

$ sudo fsck.hfsplus -f /dev/sdg2

Once this completed, I was able to mount the drive normally by just clicking on it in the File Manager.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .