Mount a HFSPlus disk with read/write permissions in Linux

9

1

I realise that this question is similar in nature to this question, but I'm hoping to specifically bring more attention to an additional problem in one of the comments of this answer to that question.

I've taken out the hard drive of an old MacbookPro and I'm trying to mount it on my Elementary OS box, where it automatically mounts it as read-only. I want to gain r-w access to this drive.

Following the procedure as given in the answer linked to above, after running

sudo mount -t hfsplus -o remount,force,rw /dev/sdc2 /media/myharddrive

I get

mount: warning: /media/myharddrive seems to be mounted read-only.

This has been noted by a comment on that question, but hasn't gained enough attention to reward an answer. How come it's still read-only? Isn't that what force ensures?

The following may or may not be relevant:

I also ran sudo fsck.hfsplus -f /dev/sdc2 following the blog post linked to in the answer and added the -f flag after fsck didn't want to perform a check of a journaled system. this ran nicely up until

** /dev/sdc2 ** Checking HFS Plus volume. ** Checking Extents Overflow file. ** Checking Catalog file. ** Checking multi-linked files. Orphaned indirect node iNode28863935 ** Checking Catalog hierarchy. ** Checking Extended Attributes file. ** Checking volume bitmap. ** Checking volume information. ** Repairing volume. ** Rechecking volume. ** Checking HFS Plus volume. ** Checking Extents Overflow file. ** Checking Catalog file. ** Checking multi-linked files. ** Checking Catalog hierarchy. ** Checking Extended Attributes file. ** Checking volume bitmap. ** Checking volume information. ** The volume myharddrive was repaired successfully. *** glibc detected *** fsck.hfsplus: munmap_chunk(): invalid pointer: 0x00000000022f9e30 ***

followed by a backtrace and a memory map. The fsck call appears to have had no effect on my drive, neither good nor bad.

Any pointers on how to get read-write access to my drive, without booting OSX, would be greatly appreciated.

EDIT Michael Kjörling's comments and answer solved my fundamental issue of accessing my data. However, the questions in bold above haven't been addressed yet, so I've edited the question to emphasise this issue, leaving the question open for future users.

kinbiko

Posted 2015-05-18T13:38:21.527

Reputation: 141

Why do you feel the need to run chmod to grab your data off the disk? The easy solution would seem to be to just do a read-only copy to some other file system, then fix permissions and ownership there if needed. – a CVn – 2015-05-18T13:40:05.657

@MichaelKjörling I don't even have read permissions of the files I'd like to copy – kinbiko – 2015-05-18T13:44:46.180

Running through sudo you should have, since root bypasses all file system permissions checks. That does, of course, assume that your permissions problem is about file system level permissions. – a CVn – 2015-05-18T13:45:28.543

@MichaelKjörling even with sudo I get cp: omitting directory Documents/. when trying to copy Documents to my local hard drive – kinbiko – 2015-05-18T13:49:27.840

1That's not a permissions problem, though. – a CVn – 2015-05-18T13:50:52.280

@MichaelKjörling You're right, it's a "picnic" problem on my end;) Thanks! Although it doesn't answer the questions I asked, it does provide a solution to my problem! – kinbiko – 2015-05-18T13:54:26.823

I just now posted an answer putting together what we found out in the comments, and how to fix that. I suggest that you edit your question to incorporate the details we found out in the comments, and if my answer does answer your question, an upvote and accept is very much appreciated. Hope you'll be able to get your data out without any further problems. – a CVn – 2015-05-18T13:56:05.660

Have you tried to turn off journaling? – harrymc – 2015-05-21T19:59:16.943

@harrymc How would you do that on a without using OSX? An answer explaining how to do it, and why, would be interesting. – kinbiko – 2015-05-21T20:03:16.603

Answer posted . – harrymc – 2015-05-21T20:36:55.527

Answers

4

As we found out in the comments, there are two possible problems at hand here:

  1. You are trying to run the copy as a regular user. This may cause reading the source files to fail because you don't have read permissions to them. This is easily corrected by running the copying through sudo just like you did the mount.
  2. You get cp: omitting directory Documents/ when trying to run the copying through sudo. That's not a permissions problem at all, and can be fixed by simply telling cp to include subdirectories.

Putting these two together, you should be able to copy your files using a command like sudo cp -av /media/myharddrive /somewhere/else, where /somewhere/else exists and is writable.

The -v parameter isn't strictly needed, but after half an hour or an hour of just waiting, you might appreciate the files being listed as they are being copied. Note that if you have a very large number of small files, the screen refreshes may reduce the throughput of the copying; in that case, simply minimize the window and check on it occasionally.

-a tells cp to operate in "archive" mode, preserving as much as possible about the files it is copying, including subdirectories. Or you could use -r to tell it to only preserve the directory structure.

Using this, you should be able to copy the files to a more suitable location where you can work with them more freely, without being restricted by the read-only limitation of HFS+ file system support.

a CVn

Posted 2015-05-18T13:38:21.527

Reputation: 26 553

I've updated the question to specifically address the mounting issue, and I won't accept your answer as it does not answer this. I'm happy to give you a bounty however, when the time runs out. – kinbiko – 2015-05-18T14:39:59.100

I have exactly the same problem as OP and have tried mounting with those flags under sudo, tried mkdir under sudo in the mounted drive and get this error: mkdir cannot create directory 'test': Read-only file system – James Heald – 2016-03-20T17:46:13.190

I had the same issue as OP and your answer seemed to do the trick. Thanks! – fady – 2017-04-05T20:21:11.137

0

I think that your problem is basically how to turn off journaling without using OSX.

This requires the binary editing (hacking) of the disk header, and as a result the disk space taken up by the journal will probably be lost.

Here are pointers to two rather similar C programs that claim to do just that :

I cannot guarantee that these programs will not destroy the disk, so I suggest that you try this out on a backup image of the disk.

This post might be useful : How can I mount a disk image?.

harrymc

Posted 2015-05-18T13:38:21.527

Reputation: 306 093

0

I had the same problem a lot and what I've learned so far: doing a successful fsck is essential. As this is not working at your machine I think this should be your approach for a fix:

  • which version of hfsprogs / fsck.hfsplus have you installed?
  • on my machine (running Debian) I installed it from source (using the downloads from a different source)

    wget "http"://"gentoo.osuosl.org/distfiles/diskdev_cmds-332.14.tar.gz"

    wget "http"://"gentoo.osuosl.org/distfiles/diskdev_cmds-332.14_p1.patch.bz2"

    tar xzf diskdev_cmds-332.14.tar.gz

    bunzip2 -c diskdev_cmds-332.14_p1.patch.bz2 | patch -p0

    cd diskdev_cmds-332.14

    make -f Makefile.lnx

    cp fsck_hfs.tproj/fsck_hfs /sbin/fsck.hfsplus

    cp newfs_hfs.tproj/newfs_hfs /sbin/mkfs.hfsplus

    ln -s /sbin/fsck.hfsplus /sbin/fsck.hfs

    ln -s /sbin/mkfs.hfsplus /sbin/mkfs.hfs

This way fsck worked for me all the time now with my hfs+ disk.

Rudolf

Posted 2015-05-18T13:38:21.527

Reputation: 101