11/11/2009

Resize your existing OSX partitions to make some space for Ubuntu and a "Shared" partition

(For the background, see Dual booting OSX and Ubuntu on a Macbook PRO)

To squeeze Ubuntu to my Macbook Pro I actually prefer reinstalling from scratch since Apple installs quite some unused stuff. But, if you don't mind losing some gigabytes, just proceed here, this is the "less destructive" way to go since your original operating system (and thus your home directory with all your documents) remains intact if the partitioning proceeds without error.

Please take my word as warning: Although I'm using dual and triple boot computers for years and the described procedure works for me (in fact I'm doing it whilst writing this article), I can't take any responsibility that it will work for you as well, and I can't take responsibility for any damage or loss you may encounter. If you still choose to follow me, please, backup your home folder NOW.

I'll tell you a short story: about three years ago, I decided that EXT3 is the way to go on my 1.8TB RAID containing about 800GB of data. It was NTFS, and since there was no utility to convert NTFS partitions to EXT3 and I didn't have a 1TB drive at my disposal (at the time 300GB was the top HDD size, at least in what I could have bought for my hardly-earned money), so I decided to take the risk and proceeded without backup. Using GParted I planned to decrease the size of the NTFS partition to 900GB, and would have created a 900GB EXT3 behind it, would have copied everything to the EXT3, then would have deleted the NTFS & would have resized the EXT3 to use the whole drive, having 1.8TB again. If I'm not mistaken everything went well up till the last step: the NTFS was copied, was deleted, and the EXT3 resize failed.

Early version of GParted? Data inconsistency? No clue. But the process was stuck, and after a day (you can imagine that day!) I had to stop it and start looking for ways to retrieve my data. Fortunately I was able to get back almost everything from the deleted NTFS partition and by now I have external drives backing up my RAID with rsync regularly (and I'm thinking about migrating my backups to EC2 or another cheap cloud-provider); I have learnt from my own mistake, so you should learn too: MAKE BACKUPS when dealing with such sensitive issues like filesystem-resizing operations.

Let's go! Start Applications->Utilities->Disk Utility and click on your Hard Drive on the left panel. Now on the right side, click Partition.



If you have your original installation, probably you will have one big partition named "Macintosh HD" like me here. We will have to shrink this partition so that our little Karmic Koala fits here too. My preferred layout is the following:

OSX As I will have Logic Studio installed which will take like 60 gigs, I will have to leave a huge partition for OSX. So I'll make it 74GB (I tell you how I came up with this number: I tried before and Logic just did not fit on 64GB :-)
Shared Will be visible from both Ubuntu and OSX, containing the documents we are working with: videos, pictures, source-files, etc. Thus, it should fill up the remaining space from all the other partitions. Since the HFS driver in Linux is not able to read/write journaled HFS partitions, we will have to change the type of this partition to non-journaled HFS. It should be non-case-sensitive, since Adobe products are fooled with case-sensitive file-systems. So, it will be "Mac OS Extended", which is "non-case-sensitive/non-journaled".
Ubuntu The Ubuntu partition will contain the Linux OS. 16GB will do for Karmic Koala.
Swap The swap partition is the virtual memory; you have to set the size depending on the amount of RAM you have. I have 4GBs, and since I want to use Hibernation I have to set it to at least 4GB (see [Swap partition size for 4GB RAM - Super User]). If hibernation is not needed, you can go away with 1GB as well.

I have a 128GB drive, so this is how it will look like:
  • OSX(74GB)
  • Shared(34GB).
  • Ubuntu(16GB)
  • Swap(4GB)

Before starting to partition the drive, I advise to sit down in front of an empty paper and try to come up with the proper numbers of your own. If you only go to the net with OSX, and you'll just install OpenOffice, 16GB should do for the OSX partition. Ubuntu is also quite happy with the 16GB, so if you sacrify 1GB for SWAP (in case you don't mind Ubuntu's hibernation), you can allocate all the remaining space to the SHARED partition, since it can contain all your documents, pictures, movies, music; reachable from either Ubuntu or OSX. The main advantages of this setup are:
  • if you happen to reinstall either OSX or Ubuntu later on, and you only store your data on the shared partition, you won't lose anything
  • you only have to work out a regular backup-procedure to the SHARED partition, since everything on the OSX and UBUNTU partition can be regenerated by a reinstallation.
To create the partition layout (don't bother with the size just yet - we'll change that in a sec), we will have to click on the rectangle representing the HDD (which says "Macintosh HD"), and then click the [+] sign next to the dimmed "Option" button, which makes a new partition. This results in two partitions:



Now click on the bottom rectangle on the left side ("Macintosh HD 2" on the picture) and click on the [+] sign again. We have three partitions:


Click on the bottom rectangle again ("Macintosh HD 2 2" above), and [+] again. We have four partitions finally:


So far, so good - we will just have to fix the sizes and the names now. Apple's Disk Utility is a tricky one, since if we change the size of a partition on top, it also changes the size of the partitions below. So we'll go from the bottom.

Click on the last partition on the left side ("Macintosh HD 2 2 2" above) Triple click on the Name textbox to select its contents and enter the new name: "Swap". Although the name we enter here will be erased with the filesystem itself when we install Koala, we'll enter the names so that we clearly see what we are doing. The format can stay since we'll delete this partition anyway (and we don't have the choice to select Linux Swap anyway), click on size and enter your preferred swap size. I will enter 4.4GB, and I hope this fixes the hibernation which didn't work in previous installations. Press Enter to update the rectangles:


Three more to go. Click on the rectangle above the one we just worked with ("Macintosh HD 2 2 1" above) to select it. This is the partition for the Linux Operating System. Enter a descriptive "Name" used only whilst partitioning: "Ubuntu". Format can stay again since the partition will be erased anyway by the Ubuntu installer. The size is 16GB. Enter:


With me yet? Let's go. Click on the rectangle "Macintosh HD 2 1", and enter "Shared" in the Name: field. Now click on the Format drop-down list and select "Mac OS Extended" (Do you remember? This is the non-case-sensitive/non-journaled HFS stuff from above, so that Linux can read and write it). The size is 34GB (or whatever your Shared partition size will be). Now press Enter and the rectangles will be updated:


Now you can freely click on any of the rectangles (e.g. partitions) to verify their size. If you are satisfied with the results, click Apply.


Smart Snow Leopard confirms the non-destructive manner of our operations. Since you have already made plenty of backups of your data, you can click on the Partition button right? After making sure your backups are intact, click Partition to proceed.

Now OSX verifies the disk, and executes the partitioning. In a couple of seconds/minutes, you'll see the results:



Now you can proceed to Install Ubuntu 9.10 "Karmic Koala" on an already partitioned drive.

2 comments:

  1. There is a problem for me. I am trying to follow this to dual boot Ubuntu 10.04(PPC version) on my Powerbook G4. I can change the volume schemes to have 4 partitions, but they are greyed out and it says, "This disk contains the startup volume and can't be partitioned."

    Any ideas?

    ReplyDelete
  2. Eliot, although I don't have any experience with pre-Intel macs, but I suspect the online resizing of the partitions like in the article is only possible with the Intel macs. You'll have to boot from the install disc and do the partition from there as suggested by this forum thread.

    Hope this helps!
    Lajos

    ReplyDelete