Those of you who have ever seen me using my laptop, or who have read my blog before, probably know that I use Linux on my MacBook Pro and love it (Linux and the MacBook Pro.) A few months ago I switched to Linux as my main OS, and I now use it 95% of the time that I’m using my computer. However, there are still a few issues with the setup, one of which is that there are still some tasks that I like or need to use Mac OS for, namely video editing and Photoshop (I like Gimp, but it’s no Photoshop.) There’s no easy way to remedy that situation, so the only choice is to boot up into Mac OS when I want to use those features, and then back into Linux afterward. But then there’s the problem of files. My usual method of sudo -s and then copying files that I need via command-line becomes tiresome, and if there’s a file that I created or updated in Linux and that I want to use on OS X, I have to use a USB key. Well no more!
I had been considering creating a partition specifically for my home directory, and then configuring Linux and OS X to use the partition for my home directory, but I think they might end up fighting over it, especially since Linux can’t write to journaled HFS+ partitions, and Mac OS X can’t even see ext partitions. So I came up with another solution. I made all the directories I wanted in OS X (which is where I still have the majority of my documents) read-write (steps below,) and then symbolically linked them to my home directory in Linux. So far it works like a charm! Here are the steps:
First, boot into OS X. You need to disable journaling on your Macintosh HD partition. Warning! Disabling journaling can lead to file system corruption! You should definitely back up your files at this point, and more frequently than usual after doing this. Open a terminal and type:
sudo diskutil disableJournal Macintosh\ HD
Now reboot into Linux. If you’re going to use your Mac HD to store all your Documents and such, then you don’t want to have to mount the partition manually all the time. Fortunately, we can get Linux to mount it manually by giving the partition a permanent mount point and then putting it in /etc/fstab. So whip out you’re favorite text editor (with sudo) and edit /etc/fstab. Add the following line:
/dev/sda2 /mnt/MacintoshHD hfsplus rw, nodev,nosuid,uhelper=udisks
If you haven’t done anything crazy to your partition scheme, then your Mac HD partition should be /dev/sda2. It’s important that you write “MacintoshHD” without spaces. I tried “Macintosh\ HD” and fstab didn’t seem to like it. Now do “sudo mkdir /mnt/MacintoshHD” (again, no spaces) to create the mount point. Great! Now you can simply “sudo mount /dev/sda2” and your Mac HD will be mounted.
The next step is to get all your files on Mac HD read-write-able on Linux to your user. This is the somewhat sketchy part. You need to change you your home directory, and “chmod -R go+rwx ” all the directories that you want access to. The first thing I tried was “chmod -R g+rw” and then adding my user to the dialout group, but apparently either I am missing one of the intricacies of user administration on Linux or there is something more going on here. No, giving every user on the system read-write access to all your files probably isn’t the best idea. If you’re hosting a server on your Mac, or you have a multiuser system, then I strongly suggest that you don’t do this. I’m not hosting any public servers on my laptop, and I don’t mind taking this particular risk for a very important bit of added functionality, so I did it. Ultimately it’s up to you.
The final step is to symbolically link the directories to your home folder on Linux. Take all the files and directories you want to save out of the directories you want to replace in Linux (assuming you want to use the same directories on Linux and OS X,) and then delete the directories themselves. All you need to do now is “ln -s /mnt/MacintoshHD/Users/your_user/Directory ~/Directory” for all the directories you want.
I’ve done this for my Documents and Music directories, and if it works I’ll probably do the same for Desktop, Downloads, and Pictures. The only downside I’ve noticed so far is that you can’t trash files from the directories on the HFS+ partition; you have to delete them straight away. It’s not too bad, but I wouldn’t be the first person to accidentally delete something important. And I don’t think there’s a way to undelete a file on HFS+ like there is on ext. Other than that it’s working great!
UPDATE: This post used to say that you have to do “chmod -R go+rw”, when in fact you have to use “chmod -R go+rwx”. I’m not sure why, but you won’t be able to access any of your OS X user’s subdirectories if you don’t.
UPDATE 2: I’ve also noticed that read/write -ing onto my Mac OS partition is a little slow. Although I don’t know for sure, I imagine that this is because it takes time to “translate” the files from one file system to another. It has a transfer rate of about 20 Mb/s, which is still pretty fast, and not noticeable for my day to day usage, but it’s something to consider.