196

I plugged in my external harddrive (which was formatted on my Mac into HFS+ journaled) to my Ubuntu desktop 9.04 64bit. I am not able to get the drive to mount with write capability, how do I do that? Right now all I'm getting is read access, I tried

sudo mount -t hfsplus /dev/sdf2 /media/"Portable HD"

but that still gave me only read access... ideas??

GiH
  • 3,977
  • 13
  • 43
  • 57
  • I feel like the answers to [this question](https://askubuntu.com/q/100167/218436) are far better, easier, and safer than the answers provided here. – Mike Williamson May 31 '19 at 18:04

5 Answers5

223

First, make sure that you have hfsprogs installed. Example installation command:

sudo apt-get install hfsprogs

Next, mount or remount the HFS+ drive; commands need to be as follows:

sudo mount -t hfsplus -o force,rw /dev/sdx# /media/mntpoint

or

sudo mount -t hfsplus -o remount,force,rw /dev/sdx# /mount/point

Finally, if the drive was improperly unmounted or has otherwise become partially corrupted run fsck.hfsplus (provided here by Jayson) as such:

sudo fsck.hfsplus /dev/sdx#
user72923
  • 887
  • 8
  • 19
  • 30
Digiground
  • 2,239
  • 2
  • 13
  • 3
  • 9
    Thank you very much for providing a Linux only solution! ^_^ – FCTW May 31 '12 at 20:22
  • 1
    this doesn't work for me, still complains of being read-only. Wikipedia suggests forcing rw mode risks corruption and the only way is to disable journalling on Mac side before mounting under Linux http://en.wikipedia.org/wiki/HFS_Plus#Linux which sounds plausible to me – Anentropic Jun 28 '12 at 06:54
  • For those on arch: http://aur.archlinux.org/packages.php?ID=6709&comments=all – slf Sep 12 '12 at 02:21
  • 14
    I'm on Ubuntu 12.04, the remount command should be like this `sudo mount -t hfsplus -o remount,force,rw /dev/sdx# /mount/point`. Then must use root to read/write data. – Coc Sep 15 '12 at 10:31
  • @Anentropic they were only found to corrupt drives >=2TB, which isn't a problem for me – slf Mar 28 '13 at 01:22
  • 21
    Why is this not marked as the answer? – Jonathan H Jun 08 '13 at 09:15
  • I'm on Fedora 19, and the remount command is same as the one in comment from @Coc above. Thanks! – mkelley33 Oct 12 '13 at 21:01
  • 5
    @Digiground and @Coc both fail with `mount: warning: /media/mount/point seems to be mounted read-only.` on Ubuntu 13.04 with hfsprogs installed. – here Dec 24 '13 at 04:56
  • This is answer is wrong, as it does not hint on disabling Journaling. -o force does *not* override this. – rurban Mar 05 '15 at 12:31
  • 1
    @here I've raised a [question](http://superuser.com/questions/916225/) to address just that issue. – kinbiko May 21 '15 at 20:11
  • 1
    in fstab: `UUID=YOUR-12345-UID /media/MountPoint hfsplus defaults,force 0 0` – Leonardo Oct 23 '15 at 00:29
  • 3
    If the disk has a problem, it will stubbornly only mount read-only. Verify/repair disk in OSX using Disk Utility as fsck.hfplus won't run "because it's a journalled file system". – Greg Bell Dec 03 '15 at 00:04
  • 1
    using this code I get the following error: `mount: wrong fs type, bad option, bad superblock on /dev/sdb2, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so.` Any ideas what the problem may be? I am trying this with a SSD, if this is relevant. – McLawrence May 30 '17 at 16:10
  • 1
    On 16.04 this answer worked but I had to use apt install hfsplus not hfsprogs – AlanObject Nov 02 '17 at 18:21
  • After running these commands, my drive no longer mounts in OSX. Why might this happen? – jonathanking Apr 10 '18 at 17:07
  • 1
    @McLawrence were you able to mount your SSD with rw permission ? – SudarP Jan 26 '19 at 00:59
82

You need to turn off the journaling if you want to write to it from Ubuntu. Ubuntu only has support for writing to non-journaled HFS+ volumes.

On your Mac:

  • Open Disk Utility under Applications -> Utilities
  • Select the volume to disable journaling on.
  • Choose Disable Journaling from the File menu. (On later Mac OS versions you'll have to hold down the option button when you click the File menu. Or if you like Apple+J)

Disabling journaling from HFS+ is still possible up to OS X Yosemite 10.10

John T
  • 163,373
  • 27
  • 341
  • 348
  • 5
    Do note that "Disabling journaling on your main OS X partition is not recommended however as journaling is an important feature of any filesystem that can prevent damage and data loss" (https://help.ubuntu.com/community/hfsplus) – Hay Nov 06 '10 at 13:00
  • @Hay you can re-enable journaling. All it does is help the system recover faster in such an event (ie. abnormal shutdown). Not the end of the world. – John T Nov 06 '10 at 16:15
  • 12
    No, that's not all journaling does. It also helps prevent filesystem corruption, which could be serious enough to only be fixable with a reformat. – Wade Williams Apr 27 '11 at 04:26
  • 8
    in macos 10.6.8, in step 3, open the file menu with "option+alt" pressed – commonpike Jun 10 '12 at 17:29
  • 2
    @JohnT Could you please provide a source for the fact that "Ubuntu only has support for writing to non-journaled HFS+ volumes" please? I'm doing some research on HFS+ and it would be very useful. Thank you. – kalaracey Jan 13 '13 at 03:37
  • Just to cite the reference here: the current [Linux hfsplus documentation](https://www.kernel.org/doc/Documentation/filesystems/hfsplus.txt) describes the "force" options as: "Used to force write access to volumes that are marked as journalled or locked. Use at your own risk." – ckujau Feb 07 '14 at 12:23
  • For what it's worth: I just disabled journalling on a HFS+ volume on OSX 10.9.1, they either re-instated it or holding the option key still works. – Marlies Mar 22 '14 at 17:13
  • Why should someone use a proprietary solution (i.e Mac OS) to write an USB? This shouldn't be marked as the solution, the unproprietary solution provided by @Digiground is way better. – Denys Vitali Mar 03 '16 at 07:29
  • Note that linux now supports read/write to journaled HFS+ . See https://superuser.com/a/365270 – Acorn Apr 03 '22 at 18:28
35

You can enable writing to HFS+ in Linux even if you didn't disable journaling. In addition to hfsplus which you already have, you need to have hfsprogs installed:

sudo apt-get install hfsprogs

Then, use the -o rw,force option.

If the drive is not mounted yet:

sudo mount -o force /dev/sdX /your/mount/point

If the drive has been mounted automatically (as it should be on a desktop system like Ubuntu), add remount to enable write:

sudo mount -o remount,rw,force /mount/point

or

sudo mount -o remount,rw,force /dev/sdx

/mount/point would usually be something like /media/Your_drive_label. /dev/sdx is your HFS+ device (eg. /dev/sdb1).

Use mount -l to find which device is already mounted on which mount point.

If the Mac disk uses the newer Apple "Core Storage", you may also need to add a sizelimit=N option, as detailed in this answer.

Finally, you will still have the problem that you need to either be root to write to the drive, or use bindfs as shown in this answer.

mivk
  • 3,441
  • 36
  • 33
  • 1
    from the answer of Digiground, do you not miss the rw part in the command?? I succeeded with his options. – meduz Jan 26 '12 at 12:44
  • @meduz: I did not need "rw" in Ubuntu 10.04. I seem to need it now in 12.04. So I have edited the reply to add it. – mivk Aug 14 '12 at 06:48
  • Does this need disabling journaling? – Makmeksum Dec 16 '19 at 06:08
  • @Makmeksum : No, this is the alternative if you cannot disable journaling and then re-enable it. And it's easier too. – mivk Jun 21 '20 at 15:03
  • excellent! also worth noting that after transferring the files as root, you can then `sudo chown -R ` – Dominik Aug 16 '20 at 16:47
  • Do any of the commands in the answer risk damaging the disk or files in any way? I'm paranoid due to needing to do this on a work backup drive. – authentictech Nov 06 '21 at 19:40
  • 1
    @authentictech: if there is some strange bug in the driver, yes, it might damage the filesystem. Which is why it is mounted as read-only by default. But I have used this many times with many different HFS+ disks, and have not seen a problem. I just had to `sudo chown -R $macuserid $Any_added_folder` before unmounting (where in practice, $macuserid was usually 99; check the user:group of pre-existing files and folders).Or `sudo chmod -R a+rwX $Any_new_or_modified_folder` to just give write access to anyone. – mivk Nov 06 '21 at 20:07
14

Have you tried to match permissions?

By default, Mac OS X formats volumes in journaled HFS+ volumes. Journaling is a feature that improves data reliability, and unfortunately it makes HFS drives read-only in Linux.

To disable journaling, just boot into OS X and fire up Disk Utility. Click on your HFS partition, hold the Option key, and click File in the menu bar. A new option to Disable Journaling will come up in the menu. Click that, and reboot into Linux. You should have read and write access to your HFS partition—however, the permissions on your Mac user's home folder will prevent you from reading or writing those files. we just need to change our UID in one OS so that it matches the UID in the other. Unless you have a reason for choosing otherwise, we're going to change our Linux UID to match our OS X one, since it's a bit easier. By default, the first user in OS X has a UID of 501, but you can double check this by going into System Preferences in OS X, right-clicking on your user, and hitting Advanced Options. If your User ID is something different from 501, replace 501 with your other UID in the terminal commands below.

Boot into Linux (we're using Ubuntu in this example) and fire up the Terminal. First, we're going to add a temporary user, since we don't want to edit a user that we're currently logged into. So, run the following commands in the Terminal, hitting Enter after each one:

sudo useradd -d /home/tempuser -m -s /bin/bash -G admin tempuser

sudo passwd tempuser

Type in a new password for the temporary user when prompted. Reboot and log in as tempuser. Then, open up the Terminal and type in the following commands, once again hitting enter after each one (and replacing yourusername with your Linux user's username):

sudo usermod --uid 501 yourusername

sudo chown -R 501:yourusername /home/yourusername

This will change your Linux user's UID to 501 and fix your home folder permissions so that you still own them. Now, you should be able to read and write to both your Mac and Linux user's home folder, no matter what OS you're logged into.

You may also want to fix your login screen, since by default Ubuntu won't list users with a UID of less than 1000. To do this, just open a Terminal and run gksudo gedit /etc/login.defs and search for UID_MIN in the text file. Change that value from 1000 to 501, and when you reboot your user will be listed in the login screen.

http://lifehacker.com/5702815/the-complete-guide-to-sharing-your-data-across-multiple-operating-systems

Zach Latta
  • 159
  • 1
  • 9
Steve Alfano
  • 141
  • 1
  • 2
  • 1
    great solution! you've just saved me a few hours :) the only thing to add is delete the tempuser --> sudo userdel tempuser – Feida Kila Oct 31 '11 at 23:12
3

Just in case this helps anyone in the future - if you're not even able to get the drive to mount in Read-Only mode, it might be because the drive uses Apple Core Storage, which is a wrapper around HFS+. See here:

Mounting HFS+ partition in Ubuntu

Mounting HFS+ partition on Arch Linux

villasenor
  • 91
  • 7