217

I have a HFS+ journaled external hard-drive and need to be able to write to it on Ubuntu. I don't have access to my Mac, it's thousands of miles away and I won't have access to it for three months.

Can anything be done without losing the data on the HDD?

Melebius
  • 11,431
  • 9
  • 52
  • 78
oppochips
  • 2,171
  • 3
  • 13
  • 4
  • ubuntu-MATE caja users: Whichever solution below you pick, doing a killall caja && caja . will help caja to „get the news , that the folder is now actually writable. – Frank N Jun 10 '19 at 10:27

5 Answers5

225

See How to mount a HFS partition in Ubuntu as Read/Write? - Super User

To quote from the second/third answer down:

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/sdXY /media/mntpoint

or

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

...

Finally, if the drive was improperly unmounted or has otherwise become partially corrupted run fsck.hfsplus ... as such:

sudo fsck.hfsplus -f /dev/sdXY

There is a goldmine of other information there regarding the mounting of HFS+ filesystems.

Richard
  • 8,502
  • 11
  • 47
  • 72
  • thanks, I'll give it a try. The info I'd found pointed out that ubuntu couldn't handle journaled htfs+ drive, and said that it had to be "unjournaled" in OSX. I don't have access to OSX for the next three months and thus can't reverse the journaling. – oppochips Aug 14 '13 at 13:35
  • 1
    I tried and get sudo mount -t hfsplus -o force,rw /dev/sdb2 /media/sdb2 mount: /dev/sdb2 already mounted or /media/sdb2 busy mount: according to mtab, /dev/sdb2 is mounted on /media/1ad12b58-c2f2-39d3-955f-54ea66a96b2b The drive (a hfs+ journaled volume) mounts as read only. is it possible to write to it without having to undo the journaling on mac os? I tried the last command and get ** Checking HFS Plus volume. fsck_hfs: Volume is journaled. No checking performed. fsck_hfs: Use the -f option to force checking. – oppochips Aug 14 '13 at 13:47
  • From the link posted above : "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)"  I don't have access to a mac,, is it possible to gain read and write access on the drive without losing the data? thanks b
    
    – oppochips Aug 14 '13 at 13:56
  • You should try: sudo mount -t hfsplus -o remount,force,rw /dev/sdXY /media/mntpoint (or leave out /dev/sdXY and point it to where it is currently mounted) instead. I will edit this into my answer. – Richard Aug 14 '13 at 14:28
  • 1
    thanks. What do I need to put instead of "mountpoint" ? I tried sdb2 and get sudo mount -t hfsplus -o remount,force,rw /dev/sdb2 /media/dev/sdb2 mount: mount point /media/dev/sdb2 does not exist and then tried sudo mount -t hfsplus -o remount,force,rw /dev/sdb2 and got : – oppochips Aug 14 '13 at 14:37
  • it is mounted at /dev/sdb2 according to mountmanager – oppochips Aug 14 '13 at 14:41
  • OK, you probably just need to create the directory with sudo mkdir /media/dev && sudo mkdir /media/dev/sdb2. Optionally set permissions if you're going to not write to it as root with sudo chown -R $USER /media/dev – Richard Aug 14 '13 at 14:53
  • I created the directories with the commands above. sudo mount -t hfsplus -o remount,force,rw /dev/sdb2 /media/mntpoint gives me : mount: mount point /media/mntpoint does not exist I also tried sudo mount -t hfsplus -o remount,force,rw /dev/sdb2 and get a long output including The command is `mount [-t fstype] something somewhere'. Details found in /etc/fstab may be omitted. – oppochips Aug 14 '13 at 22:01
  • I also tried sudo mount -t hfsplus /dev/sdb2 /media/1ad12b58-c2f2-39d3-955f-54ea66a96b2b mount: /dev/sdb2 already mounted or /media/1ad12b58-c2f2-39d3-955f-54ea66a96b2b busy mount: according to mtab, /dev/sdb2 is already mounted on /media/1ad12b58-c2f2-39d3-955f-54ea66a96b2b – oppochips Aug 14 '13 at 22:37
  • and sudo mount -o remount,rw,force /media/1ad12b58-c2f2-39d3-955f-54ea66a96b2b /dev/sdb2 mount: you must specify the filesystem type – oppochips Aug 14 '13 at 22:41
  • OK, try: sudo mount -t hfsplus -o remount,force,rw /dev/sdb2 /media/dev/sdb2 (that exact command). – Richard Aug 15 '13 at 03:42
  • Thanks. I got $ mount: /media/dev/sdb2 not mounted or bad option – oppochips Aug 15 '13 at 04:59
  • Hmm... maybe sudo mount -t hfsplus -o remount,rw -force /dev/sdb2 /media/dev/sdb2? Make sure you have hfsprogs installed, too! And you may be unable to write to the disk until you do an fsck as instructed. – Richard Aug 15 '13 at 18:17
  • sudo mount -t hfsplus -o remount,rw -force /dev/sdb2 /media/dev/sdb2 does nothing. Yes, hfs progs is installed, and an fsk gives me sudo fsck.hfsplus /dev/sdb2 ** /dev/sdb2 ** Checking HFS Plus volume. fsck_hfs: Volume is journaled. No checking performed. fsck_hfs: Use the -f option to force checking. – oppochips Aug 16 '13 at 06:48
  • It "does nothing"? There should be no output from that command if it works correctly; see if there are any files in /media/dev/sdb2. I changed the fsck command in my answer to include the -f option. – Richard Aug 16 '13 at 14:49
  • Yes, no output. With the new fsck command I get : ** /dev/sdb2 ** Checking HFS Plus volume. ** Checking Extents Overflow file. ** Checking Catalog file. ** Checking Catalog hierarchy. ** Checking Extended Attributes file. ** Checking volume bitmap. ** Checking volume information. ** The volume Storeva-USB appears to be OK. --- I tried ejecting, going through the commands again, rebooting but it's still read only – oppochips Aug 16 '13 at 15:22
  • Alright, so it is mounted (the output of ls -l /media/dev/sdb2 is your files and folders on that device) but only as read-only? – Richard Aug 16 '13 at 20:27
  • yes, it's been mounted from the begining, sorry if this wasn't clear in my initial question. I can access my files and could before we started, but still can't write to the drive, which is what I need to be able to do. The dpole emploive is journaled and I can't reverse the journaling in OSX because I don't have access to a mac and won't for a few months – oppochips Aug 16 '13 at 23:59
  • Sorry for the late reply - I had forgotten about this topic. See http://ubuntuforums.org/showthread.php?t=1420673 for a program that does turn off journaling from within Ubuntu. – Richard Aug 27 '13 at 21:40
  • Try diskutil disablejournal /dev/disk2s2, a command line alternative to disk utility's Disable Journaling:

    Don't forget to substitute disk2s2 for your actual device

    – T. Greg O'Neil May 11 '16 at 19:32
  • On Ubuntu 16.04 I get unknown filesystem type 'hfsplus'. – bparker Dec 04 '17 at 02:10
  • On recent Ubuntu you need to install hfsplus instead of hfsprogs. Please add to your answer. Thanks. – JPT Aug 09 '19 at 09:15
  • One extra info: I had to start my File Manager (Nautilus) as root to be able to write in the hfs mount point. – matt Apr 13 '20 at 08:41
44

These steps works for me (Ubuntu Studio 14.04):

sudo apt-get install hfsprogs

Check status of drive:

sudo fsck.hfsplus -f /dev/sdXY

Unmount device:

sudo umount /media/sebastian/devicename

(create folder to mount the drive)

Mount the drive with HFS+ read/write permissions:

sudo mount -t hfsplus -o force,rw /dev/sdXY /home/sebastian/foldername
  • 6
    this mounts it alright as a folder, but it is still read-only.... :( ... can't seem to find a simple way to get by the hfs+ journal system restrictions – Amphibio Feb 11 '16 at 11:01
  • 2
    This works. But why do we need force? – qweruiop Apr 10 '17 at 22:22
  • 9
    I get the following error: `mount: wrong fs type, bad option, bad superblock on /dev/sda2, missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so.
    

    `

    – Jamie Hutber Mar 22 '18 at 10:47
  • this is correct sequense of comands. start with fsck command! thanks! – skywinder Aug 29 '20 at 13:38
  • sudo fsck.hfsplus -f /dev/sdXY also did some minor repair to the drive which allowed me to mount it! I can finally access 100 GB of pictures that I thought lost – nbeuchat Nov 05 '20 at 22:00
  • I was wondering if I'd need to create the foldername folder. Yes. You will need to make the mount point. so mkdir /home/sebastian/foldername would be the second-to-last command. – gMale Jun 16 '21 at 23:24
37

I had this problem too. I tried fsck.hfsplus, umount, remount with sudo mount -t hfsplus -o remount,force,rw nothing worked for me.

What did work for me was :

  1. unmount with sudo umount /media/myMountPoint
  2. delete the mount point with sudo rmdir
  3. recreate the mount point with sudo mkdir and
  4. remount with sudo mount -t hfsplus -o force,rw /dev/xxxx /media/myMountPoint

Hope this will also work for you guys.

bob
  • 471
  • 4
  • 4
  • 3
    you saved my life! – Alex Chan Nov 30 '17 at 15:26
  • This worked for some reason. I've no idea why. The directory was empty and mounting it before deleting the directly mounted it with ro even with force,rw. Removing and recreating the directory did it. – Umar Ahmad Mar 21 '19 at 08:03
  • 1
    The reason behind '2.' is probably, that the mount point directory is 'user:user'. (ls -l to verify). In other words:sudo chown -c root:root myMountPoint/` will probably also fix it. (unmount before still necessary) – Frank N Jun 10 '19 at 10:24
  • And by my exerpience: if you don't do your mount points under /media/<username>/ but elsewhere (I like /mnt), a „smart“ Ubuntu MATE for example won't delete and (wrongly) recreate your mount folders time and again. – Easier for a mount script that lasts... – Frank N Jun 10 '19 at 10:24
16

Since I cannot comment (not enough reputation here:). I will post this answer to point out that the answer above appears to be for a hfs+ HD that is not journalled. The 'fsck.hfsplus' command needs to be issued with the '-f' option to work on a journalled volume. To avoid confusion I've copied the command below:

$ sudo fsck.hfsplus /dev/sdXY

** /dev/sdXY
[snip....]
** The volume ########### appears to be OK.

This would only run on a volume that has not been journalled. Even with the '-f' option on a journalled volume this check in itself will not allow the remounted volume to be mounted read/write. I believe journalling must be turned off.

There does not seem to be stable code available to turn off journalling from linux. See the link provided by Richard: http://ubuntuforums.org/showthread.php?t=1420673

If journalling is turned off and the disk initially mounts as read-only unmounting and remounting should allow read/write if the disk is undamaged. If it is damaged then fsck.hfsplus needs to be run.

Jonathan Gutow
  • 351
  • 2
  • 4
11

Borrowing from the previous answer, the following steps worked for me. Hopefully this is useful to others:

  1. Plug in the external HDD.

  2. Notice that Ubuntu mounts it automatically but it is read-only.

  3. Unmount the drive (I do this simply by clicking on the eject button in the file explorer).

  4. sudo apt-get install hfsprogs

  5. $ sudo fsck.hfsplus /dev/sdXY
    

    ** /dev/sdXY ** Checking HFS Plus volume. ** Detected a case-sensitive catalog. ** 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 ########### appears to be OK.

    (sudo fsck.hfsplus -f /dev/sdXY if filesystem is journaled.)

  6. Remount the drive (I do this simply by clicking on the drive in the file explorer).

  7. The drive is now read-write.

David Foerster
  • 36,264
  • 56
  • 94
  • 147