Configuring Ubuntu to mount a shared HFS partition

If you have followed along the earlier series of this article, you may have already met one of the limitations of Ubuntu's HFS support: it can't write journaled HFS volumes. Thus, it makes sense to partition the drives with non-case-sensitive and non-journaled HFS where there is a need to read/write. You can also manually disable journaling if you already finished partitioning and you've had the journaled option turned on.

A decision to take: move the home folder, or make symbolic links?
In earlier iterations of my dual-boot configurations, I had my OSX home folder moved to the shared partition. This works quite well, at least up to the point when the system starts up after a "dirty shutdown" when the regular shutdown procedure was not executed properly: like when the computer was frozen and was killed with the power switch (or facing a power-outage on an iMac, or running out of battery on macbooks). In these cases, a disk-check was performed during startup, but since the check can't finish until the computer boots up (and OSX does not wait for the check to finish, rendering the shared volume inaccessible temporarly), we may face an empty home-folder after a dirty shutdown (so you'll face a brand-new configuration, like you have just finished installation, since it uses the unmounted /Users/username folder). This can be fixed by a logout-login, nevertheless it is not nice.

Not to mention if we do the same with Ubuntu: if the home folder is moved to the shared partition and the partition is dirty on boot-up, it will be read-only; if I'm not mistaken this has resulted being not able to login to the system at all. This sounds really bad, so in my experience the best option is to leave the home folders where they are (e.g. Ubuntu will have its' home folder on the EXT3 drive, OSX on the HFS drive), and we'll make symbolic links to the documents, pictures, videos folders on the shared partition. Until we keep our documents where they belong, they will be on the shared drive.

Mounting an HFS volume on Ubuntu

There are two ways to identify a partition to mount on linux: either by the device's name (like /dev/sda1) or by its UUID, which is just a random number. The UUID option is better, since a partition will be identified even if its' name changes (like when the number of partitions changes on a drive: /dev/sda3 won't be /dev/sda3 anymore as soon as we remove /dev/sda1 and /dev/sda2).

To see some information about your partitions, you can use the command blkid:

In this screenshot (don't let yourself fooled by the appearance, this is Ubuntu having a nice gnome-theme applied, thus looks a bit like OSX, pretty neat huh? See here how to install it) it is apparent that I have four partitions, and I will have to mount the last one. I will mount /dev/sda4. Yours can be different, so double-check.

To mount a partition, first we have to create the folder where it will be mounted. Open a terminal, and enter
sudo mkdir /mnt/shared
sudo chmod 777 /mnt/shared
Now we'll add an entry in /etc/fstab. Press Alt+F2 to bring up the Run Application dialog, and enter
gksudo gedit /etc/fstab

Enter your password when it's been asked. This will bring up the contents of the fstab file in the text-editor using the proper rights to edit it (you can use vi of course but then you won't need my assistance in any case...) Add a line to the end of this file:
/dev/sda4 /mnt/shared       hfsplus    rw        0       2
Of course, replacing my /dev/sda4 with the correct entry if needed. Save the file & exit the editor.

Using UUIDs
You could also use UUID to identify the partition; I don't know why, it didn't work for me. To acquire the UUID, copy the UUID from the blkid command (or, if you are using Jaunty you can use the sudo vol_id /dev/sda4 command too), and add the fstab line like this:

UUID=aae739de-bfb8-39d6-b60a-a6e47222e74a /mnt/shared       hfsplus    rw        0       2
Somehow, even though it worked the first time, it didn't work after a reboot, so I've had to fall back to the name. If you figured out the reason, please let us know!

Now we have everything in place. If you reboot, this should mount automagically, but you can mount it right away by entering
sudo mount -a
to a terminal-window. This mounts all filesystems mentioned in fstab - since all others are mounted anyway, ours will be mounted now. To see your mounted filesystems enter
sudo mount
Hopefully your shared partition will be on the list. To shorten the list you can also use
sudo mount | grep sda4

Preparing the shared partition

The shared partition will contain our documents, pictures, music, videos, etc. Now that we have our shared partition mounted, we can create symbolic links from our home folder, so that we don't have to navigate to the shared folder manually.

First let's create the folder for our documents:
mkdir /mnt/shared/doma
mkdir /mnt/shared/doma/Documents
Don't forget to replace my name with yours of course.
sudo or not to sudo? Using multiple accounts
We don't need sudo here, since we want to keep our credentials; by repeating this same process for another user using another name, his/her documents will be on the shared partition as well. Just don't forget to logout/login with the other user's account in this case.

Now just to be sure we don't lose anything, we can move all our may-be-existing documents already:
mv ~/Documents/* /mnt/shared/doma/Documents
Now the Documents folder should be empty. We can verify it with
ls ~/Documents
It should be empty. If it is, we are ready to create the symbolic link.

Creating the symbolic link

To create the symbolic link, enter
ln -sf /mnt/shared/doma/Documents ~
in the terminal. ln -s creates a symbolic link, the f parameter replaces the Documents folder if it exists (it does). Even if it looks like (and we wouldn't have moved our documents earlier), it does not destroy anything under the old /home/doma/Documents: if we remove the link, the contents of the (now hidden) folder would reappear. But since we've been careful and moved everything out of the folder earlier, it is empty anyway.

This same procedure can be repeated with the Pictures, Videos and other folders.

Moving the folders on OSX

In order to have a nice and clean system, we should move these folders in OSX as well. Thus, if we'll go to the Documents folder, both OSX and Ubuntu will go to the same folder.

The procedure is quite similar to the previous one. Let's create a small shell-script which will help us:
mkdir /Volumes/shared/doma/$1
mv ~/$1/* /Volumes/shared/doma/$1 && sudo rm -rf ~/$1
ln -s /Volumes/shared/doma/$1 ~
Copy these lines to TextEdit, make it Plain Text (format menu) and save the file in your home folder using the name mv.sh - and don't forget to replace my name with yours! This shell-script automates all the necessary steps for OSX. We'll have to make it executable first with
chmod +x mv.sh
Now we can execute it for all the folders we want to move. For the Documents folder, enter
./mv.sh Documents
You can do the same with your Movies, Music, Pictures folder if you like - but take iTunes' and iPhoto's proprietary folder-structure into account, you'll see the details of their file-storage in Ubuntu (that's linux anyway and supposed to be lower level right?). In any case, you'll have access to your files - and if you use some other, possibly multi-platform tool to manage your pictures and music, you may end up having a quite usable multi-platform system.

Drop a comment if it works for you, tell us how you've configured your system - and don't hesitate to ask if you have a question!

Thanks for dropping by - see y'all next time!


  1. hi, could you please further explain "symbolic links to the documents, pictures, videos folders on the shared partition. Until we keep our documents where they belong, they will be on the shared drive.". I'm a little bit confuse! Is it (the symbolic link) means that the shared partition will synchronize itself with the folder that we set up or is it means that we're creating a folder inside the shared partition (yours is home) so that it appear in both mac and ubuntu....

  2. if you create a symbolic link in /Users/name/Videos which points to /Volumes/shared/Videos (e.g. using ln -s /Volumes/shared/Videos /Users/name/Videos), everything you'll copy into /Users/name/Videos will be in fact copied into /Volumes/shared/Videos (although will be visible in /Users/name/Videos as well, because of the link). So no synchronisation is needed; yet, if you format your partition containing the /Users folder, and you reinstall and you re-create the link, you'll have the videos where you've saved them... or if you reload your OS from an image you saved earlier, the link will be automatically restored, so no further action is necessary. that's what i mean by "keeping the documents where they belong". and, if you have another link from ubuntu, it will appear there as well!
    hope this helps! cheers, lajos

  3. that's really help me. mu ubuntu recognised the hfs+ partition now, without follow your guide. it's simply 'automagically' mounted (i just used psym a.k.a storage device manager to make it automount every time i login into ubuntu). however thanks for your post, if not i didn't know the fact that i could make a mac/ubuntu partition together. BUT right now i've problem to write on the hfs+ volume (without journaling), may be i need to consider your method of 'symbolic link'. i told you the progress when i done (i do ask you to lend me a helping hand during this process i just a student not as yours who really involved in this arena).

  4. hei, i make it to work today. i just load into the root by using terminal (type gksudo nautilus). from there, i chose folder that i want to transfer to (in shared partition) and drag the file that i want into it...

  5. congrats! that sounds like a permission problem. the easiest (dirtiest) fix is to give permission to everyone with chmod - this works until you are alone on your PC. but the nice solution is to change the UID of the actual Ubuntu user (1000) to 501 (this is the ID of the default OSX user) - and, of course replace the permission on the existing files as well. if interested, try to google for "change uid ubuntu" - but this is not really for the faint-hearted. i'll look into incorporating this info into the articles if i'll find the time. cheers! lajos

  6. hi, just to inform you that i've settled the permission issue by using the root ethod again. (i) type gksudo in nautilus, a root window will appear (ii) go to the folder in your shared partition and right click on it (iii) select sharing options (iv) check 'share this folder' and 'allow others to create and delete files in this folder' (v) to confirm click 'Create Share'. And then, all will work perfectly as I dreamed for! Cheers!

  7. Thanks for this grate post. I am considering buying a Mac with a Linux partition, but I have heard of fan problems with Linux on Mac. Would you recommend a Dell PC with Windows and a Linux partition instead?

  8. exlibris,

    On MacBook Pros I've never had fan problems with Linux, so I can definitely recommend those ones. Did you experience the fan problems yourself? Which models?

    I managed to get OSX running on an ASUS W2P notebook as well as a DFI LanParty X58-T3EH8 motherboard; both works after some hacking, but the user experience is just not the same. If you want the "just works" experience, you should go for a real mac! And if you want Linux's freedom you can install Ubuntu easily. Cheers! Lajos

  9. Hi doma, this is what I founded about fans and temperature in MacBook Pro with ubuntu:


    I am considering buying the las MacBook Pro aluminium, 15 inches, Intel Core i5 or i7

  10. Hi doma,

    I am using ubuntu 10.04. I have used your guide successfully, but I cannot get the symbolic link to work in ubuntu. I keep getting the error that ln "cannot overwrite directory" when I try to replace the Documents folder in my ubuntu /home/username directory with the symlink. I've tried with and without sudo. Any ideas?


  11. Hi doma,

    A couple of important things that I discovered to add to the above:

    1) Need to change permissions of /mnt/shared from ubuntu: sudo chmod 777 /mnt/shared

    2) Do NOT run the script in OSX until you confirm that you can write to the directories in shared. I initially made the /mnt/shared/Documents and other directories while I was in ubuntu, and in OSX I did not have permission to write to those directories. I ran the script and permission was denied, but my folder was still deleted in osx with the "rm" command and I couldn't undo it. So do NOT run script until you know you can write or you will lose your files. Luckily I had backed them up.

    Also, this is superficial, but you may want to make an effort to save your macbook icons for the various folders by opening "get info" for each, selecting the small icon in the top left of the window, copying it, opening "get info" for a blank folder and pasting the icon on top of the generic folder icon in the top left. Then you can replace all your generic link icons with the pretty special icons.

    3) I think its better to set things up in macbook first since they have subfolders and files in some of the folders. Make a backup copy of each folder before you run the script. This would also avoid the write problem I had in #2 above, although now you would have to change the user and group of the directories from ubuntu. If you do this, make sure you run "$mkdir /Volumes/shared/doma" first, otherwise the script will fail.

    4) In order to prevent having to change owner and group everytime you create a file in OSX, run "sudo usermod -u 501 doma" (501 is the uid for the first mac user). If you need to fix ownership, "sudo chown -R doma:doma /mnt/shared/doma".

    5) I've got everything looking good, except that I cannot get the ln -sf command to work and replace the ubuntu directories as explained, it keeps giving me the error "cannot overwrite directory". I may have to delete the directories before I can set up the links, unless you know why it isn't working.

    Thanks so much for your posts, I hope my additions help someone too.

    Note: I'm using Macbook 1,1 (Tiger 10.4) and ubuntu 10.04 on a dual-boot install.


  12. Hi doma,

    Me again. Regarding my problem with the "ln -sf" command, I was able to work around this by moving Documents and other folders to trash (so I could restore them if things didn't work out right). Then, I ran the command "ln -sf /mnt/shared/doma/Documents ~" from my ubuntu /home/doma directory (obviously changing Documents to the folder I was linking and using my name instead of doma). This worked perfectly. All of my links (like in the sidebar and pulldown menus) to the original Documents and other folder were maintained, but now properly pointed to my shared directory.

    I assume you could also "rm -sf /home/doma/Documents" from the terminal before running the ln command, but you can't restore that if you don't like it.

    Ok. With your write up, and my additions, this appears to be working like a dream. Thanks again.

    Best regards,

  13. Hi Doma,

    Regarding my problem with the "ln -sf" command, I decided to move the Documents folder (and other folders) to the trash so I could restore them if I didn't get the result I liked. Then I ran "ln -sf /mnt/shared/doma/Documents ~" from the /home/doma/ directory (obviously replacing "Documents" with the appropriate folder and using my username instead of doma. This worked like a charm. All of my links (like in the sidebar and in pulldown menus) to the original folders now point to the appropriate folder in the shared partition.

    With your posts, and my additions, my macbook osx-ubuntu dual-boot setup is a dream. Thanks.

    Best regards,

  14. Thanks for this guide! I'm trying to follow it, but when I try to move Documents and create the links (from Ubuntu), I get stuck with the following error messages in the terminal:

    ln: `/home/jksch/Documents': cannot overwrite directory

    mv: cannot stat `/home/jksch/Documents/*': No such file or directory

  15. Nathan,

    Thank you for your comments, I will investigate all of them. So far I fixed the moving issue by checking the return value of the mv command before the rm; this can be done by the double-ampersand of bash (see http://www.gnu.org/software/bash/manual/bashref.html). So the script only removes the directory if the move succeeds.

    You are also right about the permission issues. Your solution is the easiest; to give everyone permission for the shared directory (firdaus sobri solved this issue with the share/mount) but in my opinion the proper way is to have the same UID in Ubuntu as in OSX as it is mentioned a couple of comments before as a reply to the solution with the share/mount. I will re-work this tutorial with the UID change, but for now I will just incorporate your recommended chmod as a quick-fix so that the tutorial works as it should.

  16. Johan,

    I suppose you also ran into the permission issue others have discovered: the move was not done without the proper permissions, so your Document folder remained in /Users/jksch, thus the ln command cannot properly create the link having the original folder in place.

    Try running the command "sudo chmod 777 /mnt/shared" (I just added it to the article above, thanks for the discovery to Nathan), and redo the mv/ln commands. Please let us know if it helps!

    Cheers guys!

  17. Hi, thanks for your help! Now, I've tried chmod-ing the shared folder, but as I then proceed to redo the move, I'm told there is no such file or directory:

    jksch@jksch-laptop:~$ sudo chmod 777 /mnt/shared
    [sudo] password for jksch:
    jksch@jksch-laptop:~$ mv ~/Documents/* /mnt/shared/jksch/Documents
    mv: cannot stat `/home/jksch/Documents/*': No such file or directory

    Any idea what I'm doing wrong here?