ideasarehere

September 1, 2010

Resizing Volumes & Changing Partitions in Mac OS X with Disk Utility and Terminal

Filed under: workflow — Erik Dobberkau @ 19:09

This post is the result of two days messing around with my Mac to set things up the way that I want them.

Initial situation: MacBookPro, 500GB hard drive. One Partion (200GB) running Leopard, another partition (150GB) with Snow Leopard (installed for testing purposes), and the last 150GB were on partition 3 with my music samples library.

Goal: Have Snow Leopard on the first partition with not-much-more space than it needs, the User data on the second one with 250GB, and the last partition stay the same.

Now one might think working on a Mac is straightforward (it is), but when it comes to HD issues, it’s almost as bad as a Windows PC. So just in case anybody out there needs some help with a similar issue, here’s what I did.

A. Make a Backup. If you’re using Time Machine that’s fine, if not you might consider Carbon Copy Cloner.

B. Make sure your backup works, the system should be bootable and all your data should be there.

[B2 Update Leopard to Snow Leopard. Fortunately it takes less space on the disk.]

C. Changing volumes and partitions: It’s no problem to make a volume smaller (in Disk Utility you just drag the grey-striped triangle in the lower right corner of a volume), but unfortunately the space that becomes available can not be assigned to another volume straight away. You need to do this in two steps.

  1. Merge both volumes. This has to be done in the Terminal. Go to “Utilities” in your “Applications” folder (or press Cmd-Shift-U in the Finder) and launch the Terminal app. It’s just a plain text command line tool.
    First, enter diskutil list. This will display a list similar to this:

    In my case, I wanted to merge #2 and #3. Here’s the command (one line):
    diskutil mergePartitions "Journaled HFS+" new disk0s2 disk0s3
    Brief explanation: The first volume needs to have a Journaled HFS+ file system (standard in Mac OS X), otherwise all data will be wiped. We need to tell the computer that the merged partition will have the same file system. “new” is the dummy name for the merged partition, because oddly enough Mac OS keeps the name of the first partition of the merged group. Then comes the list of volume identifiers you want to merge. I only did this for two, but I’m sure you can also merge more volumes in one go. Maybe you can even write JHFS+ instead of “Journaled HFS+”, but I didn’t test it.

  2. Next, resize the big volume in the Disk Utility and create a new one in the freed-up space, or use the Terminal which is quicker but doesn’t look so fancy. The command is (sizes just my example, yours may differ)
    diskutil resizeVolume disk0s2 90G JHFS+ Users 250G
    Or use Disk Utility, drag your volume handle until the desired size is displayed (or enter it manually), then click the “+” button beneath the disk list to create a new volume.
    Note: No matter if you use the Terminal or Disk Utility, don’t panic when you get an error message during resizing. Mac OS sometime can’t allocate the disk space properly if you “over-shrink” a volume (say, from 200 to 50 GB). In this case, you may try going about half the way down, and then repeat the procedure until your volume has the desired size.

D. Phew. Now let’s move your home folder to the Users Volume, using Terminal again. Here goes (one line again):
sudo ditto -rsrc /Users/[YourUserNameHere] /Volumes/[Volume-Name]/[Folder-Name]/[Your-User-Name-Here]
The sudo ditto -rsrc command makes sure all the metadata of your files  are preserved when copied.

E. When finished, go to your System Preferences, select “User Accounts”, unlock and right-click (or Ctrl-click) on your username, select “Advanced Options” and set the Home directory to your freshly copied folder. Then you’ll have to reboot and everything should be working fine. At least it did with me. If you’re using the NoScript-AddOn for Firefox, you’ll have to uninstall and re-install it because it doesn’t “get” the new folder. The main upside of this procedure is that now you can take your user data to any other Mac by just cloning it to an external drive. Or easily back up all your Users’ data.

Please do not forget to make a backup before you do anything on (or to) your system. Backups are your friend.
Hat tip to Jon at Ransom Note Typography for the Home folder moving tip, and all the people at the Mac forums all over the Web. What I’ve written here is just a brief summary of their work. And if you liked using the Terminal, here’s a list of other things you can do with it.

[Update: The whole process does mess things up. For instance, if you have virtual machines like VMware Fusion running, you’ll need to re-assign the machine files — no big deal here. Other applications, like Native Instruments’ Kontakt sampler, may need to be reinstalled because the can’t locate certain files either. But it’s not too big a deal overall. The major downside (at least in my case) is that TimeMachine understands the new configuration as an entirely new system and re-does the whole backup.]

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress