Apr 9, 2011

How to have both Mac Os X and Linux installed and share the same home directory files

So much time since my last post! I’m sure that the best way to come back to blog posting is a nice tutorial.
I’m going to write how to have the same home directory shared between Mac Os X and Gnu/Linux. Let me call Gnu/Linux just Linux from now on.

A unique place for your working directory on both Mac Os X and Linux!

The configuration I’m proposing should be very confortable, as it works with symbolic links.
It lets you to boot either Mac Os X or Linux and have the same directories and files for your everyday use. Meanwhile, the important configuration files and directories (e.g. ~/Library for Mac Os X, ~/.config for Linux) are kept separately on their corresponding partitions.
Another advantage of this configuration is that you can have a small partition dedicated to Linux – let’s say 10GB but could be even less – just for installing the programs you need, while your videos, documents, music files are kept inside the biggest partition, the one for Mac Os X.

Disclaimer, assumptions

Basically, you will mount your Mac Os X root partition in Linux, and soft-link your important directories to your Linux home directory.
You will then use them as there were real directories in your Linux home directory. For this how to, there are a couple of things I assume that:

You have Linux installed and running natively on your Mac(Book). I’m going to give commands with sudo, so configure it if you’re not using Ubuntu-based distros!
You know your partition layout. The following is mine. I’m going to use it as example:

You have a clean Linux home directory. This means that you don’t have directories whose names are in conflict with those on your Mac Os X home directory
You are going to disable file system journaling on your Mac Os X root partition! Please read carefully this Wikipedia page about journaling and this Apple page about HFS+ journaling if you need more information.
Boot Mac Os X

Follow these instructions under Mac Os X:

Open a Terminal.

Identify your Mac Os X root partition:

Disable file system journaling for the partition:

Do a ls -n of your home directory to discover your user id uid:

My UID is 501. Keep your UID in mind, you will need it under Linux. You obtain the same results by using the command “id”.
Reboot your Mac.

Boot Linux

Follow these instructions in a linux shell.

Change your Linux user id (UID). To correctly share the same home directory between both OS, you need to have on Linux the same UID of your Mac Os X user.

(sudo usermod -u 501 dgraziotin in my case)

To have your new UID applied, either reboot or logout from every shell you opened, even from your desktop environment. Login again.

Create a directory in which you are going to mount Mac Os X root partition:

put this line at the end of /etc/fstab, as root, with your favourite editor:

Remember to change sda2 and OSX according to your settings.

Either reboot the system or type:

To mount your Mac Os X root directory in your mount point directory.

Now cd to your Linux home directory and begin to soft-link all of your important Mac Os X directories. Here are some of those I needed:

Don’t soft-link the Library directory.


Now you have the same important files shared on both Mac Os X and Linux, while the important hidden configuration files are kept in separate phyisical places.
You can listen to your Itunes mp3 collection on both operating systems. You can now develop programs under Gnu/Linux. You can reboot your machine to Mac Os X and take notes during the lectures, and so on! Hope you liked this how to, and comment it as well. Contact me if you find some mistakes or you’re in trouble!

written by dgraziotin

Dr. Daniel Graziotin received his PhD in computer science, software engineering at the Free University of Bozen-Bolzano, Italy. His research interests include human aspects in empirical software engineering with psychological measurements, Web engineering, and open science. He researches, publishes, and reviews for venues in software engineering, human-computer interaction, and psychology. Daniel is the founder of the psychoempirical software engineering discipline and guidelines. He is associate editor at the Journal of Open Research Software, academic editor at the Research Ideas and Outcomes (RIO) journal, and academic editor at the Open Communications in Computer Science journal. He is the local coordinator of the Italian Open science local group for the Open Knowledge Foundation. He is a member of ACM, SIGSOFT, and IEEE.

  • gicxjo May 21, 2012 Reply

    I did that, but Mac OSX became very unstable. It started crashing whenever it tried to read the non-journaled HFS+ partition that I wanted to share. Bummer.

    • dgraziotin May 22, 2012 Reply

      I am sorry to hear that. It never happened to me.
      Are you sure it is related to the steps described here? I do not see any dangerous commands. Disabling the journal of a filesystem can be dangerous if you have frequent power outages.
      Another reason of instability can be wrong permissions. Double check if you are using the same user ID on both sides.
      Besides that, the steps described here are nothing more than mounting a filesystem and using it.

  • seth Oct 30, 2013 Reply

    I also shared the same home directory between OS X and Linux. But sometimes, when I reboot to OS X from Linux, some(but not all) of my OS X configurations will be lost. It’s really weired. Have you experienced the same thing?

    • dgraziotin Oct 31, 2013 Reply

      Nope, as far as I remember. Please note that I do not possess a Macbook anymore. However, if this behavior is caused by the home folders’ sharing it may be the case that you are sharing some folders containing configuration files. Are you sharing some particular folders?

      • seth Oct 31, 2013 Reply

        I created a dedicated HFS+ volume for home directories and share it between OS X and Linux. This means all files in my home folder will be accessible in both OSes, including OS X configuration files. These personal configurations are stored in ~/Library. As far as I know, this directory has no sepcial meaning for a Linux distribution. So it shouldn’t be tampered when running Linux. That’s why I feel confused.

        • dgraziotin Oct 31, 2013 Reply

          As far as I understand, your approach is quite different than the one described in this post. In the post, I am not suggesting to have a shared “partition” as a home folder. This is exactly what I wanted to avoid by symlinking only the important folders.

          Even if Library is not directly employed in GNU/Linux, several “hidden” folders in your shared home directory are now employed by GNU/Linux and OS X. It might also be the case that some tasks like indexing services are changing some attributes of the Library folders and files, thus screwing OS X. I am only speculating at this point.

          In a couple of words, I encourage you to switch back to the approach described in this post. While still hackish, it is definitely safer. Keep the home folders separate, but bridge them through symlinks.

  • bolika Jun 3, 2017 Reply

    6 Years later, this tutorial is still useful…
    Thanks you for this “KISS solution” that works well for me 🙂 !!

Leave a comment