Mac OS X - Nondestructive Partitioning
There might come a time when you need to install a second version of Mac OS X on you Mac or you want to separate your documents from the operating system files. If you have a preformatted Mac or if you did a default install of Mac OS X, chances are that you only have one volume on which all of your files reside. As of Mac OS X Tiger version 10.4.6 it's possible to resize and create new volumes on your disk without losing data or having to reinstall the entire system. This process is called nondestructive since you do not lose or destroy your disk's data.
This article will guide you through the process of resizing an existing volume and creating a new partition on which you can install a new version of Mac OS X, or keep your personal documents.
The prerequisites are you have a Mac running OS X Tiger version 10.4.6 or higher. Use the Software Update tool first to ensure you have the latest version of your operating system and associated utilities installed.
Once you're ready, let's go.
Creating a Backup First
Before attempting to follow the steps in this guide, we'll make sure to have a backup of your personal documents since you never know if something is going to fail. We'll use the relatively simple tar utility to get this done.
Because your programs and open applications might be writing to the disk while you are creating a backup, the backup might be incomplete if you'd just create one while working on the system. We need to first restart into the so called single user mode to make sure no programs are using the disk.
Creating the backup
To start the system in single user mode, press the [Command] (Apple) and [S] key at the same time when starting the computer. If you've done this successfully, the screen will now have a black background and white letters on top of it.
You can use the keyboard to type commands on this screen. We'll first check the hard drive for possible errors and corruption:
This command will usually output some information on the process of checking the hard drive. Example output is as follows:
** Root file system
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking multi-linked files.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume Macintosh HD appears to be OK.
The last line should indicate that the volume is OK, if not use the [Y] key to confirm any actions to correct disk errors. Once the command finishes, we'll reinitialize (remount) the disk to make it possible to create the backup. Type the following command:
mount -uw /
Don't forget the slash at the end of the command. Next up is creating the backup. We'll store this backup at the very root of the disk (the main folder of the HD). The following command creates a large backup file containing all your documents, this can take a long time to finish so please be patient:
tar cvfp /Backup.tar /Users
You will see a list of all your files and documents scroll by line by line. As soon as the list stops scrolling and you see the command prompt "localhost:/ root# " on the screen, the backup is finished. You should now type the following command:
Your Mac will now restart once again and you can then use the Finder and your favorite burning application to store the large Backup.tar file onto a DVD or other medium. Once it is burned you can safely delete the backup file from your hard disk to regain disk space.
Resizing the Disk
Restarting in single user mode, activating services
Start off by booting into the single user mode again using the [Command] + [S] key combination at startup. Once you're back at the black and white screen, issue the following command to start up essential system services including disk management:
You should see a lot of startup messages displayed on the screen. Once things settle down, press the [ENTER] key a few times until you see the command prompt "localhost:/ root# " again.
Gathering disk information
Now that the system services are started we can use the diskutil command to retrieve information on the hard disks in your computer. Type the following command:
This command will give you a detailed overview of all volumes and disks present in your Mac. The output on my Macbook looks like this:
/dev/disk0 #: type name size identifier 0: GUID_partition_scheme *55.9 GB disk0 1: EFI 200.0 MB disk0s1 2: Apple_HFS Macintosh HD 55.6 GB disk0s2
We should now identify which volume we want to resize. In my case, it is simply called "Macintosh HD" and has a size of 55.6 gigabytes. These values can be seen under the "name" and "size" column. You can ignore entries having a type of GUID_partition_scheme as those are system entries instead of user volumes.
Once you see the volume you want to resize, write down the value in the "identifier" column. In my case this is disk0s2. We'll now first check if this disk can be resized using the following command, substitute the identifier with the one you are using:
diskutil resizeVolume disk0s2 limits
This command will print the current, minimum and maximum size of the volume, like this:
For device disk0s2 Macintosh HD: Current size: 59667668992 bytes Minimum size: 15531765760 bytes Maximum size: 59667668992 bytes
Actually resizing the volume
At this point, you should consider your new volume layout. I decided to split my 55 gigabyte volume into a 45 and a 10 gigabyte one. You can also split the volume into three or more parts if you like, just append them to the following command.
Also note that if you're doing this on a laptop, be sure to plug in the power lead as you might corrupt your hard disk if the laptop shuts down while doing the procedure.
The following command to resize the disk always starts with "diskutil resizeVolume disk0s2" (replace disk0s2 with your identifier) followed by the new size, in my case 45G. Then you can add extra partitions by appending "JHFS+ VolumeName Size" for each new partition. In my case, I'm going to append "JHFS+ Development 10G" to the command because I want a new volume called Development with a size of 10 gigabytes. The full command for my situation would thus become:
diskutil resizeVolume disk0s2 45G JHFS+ Development 10G
Upon issuing this command you will see some screen output like this:
Started resizing on disk disk0s2 Macintosh HD
hfs_truncatefs: shrank "Macintosh HD" to 12058624 blocks (was 14567302 blocks)
Finished resizing on disk disk0s2 Macintosh HD
You will need to manually reformat your new partitions.
WARNING: You must now reboot!
As indicated, type the following command to reboot your Mac:
At startup, you might see a grey folder with a question mark instead of the Apple logo, it should disappear shortly afterwards and continue to boot your Mac normally. The first few boots after resizing the volumes is slower than you are used to because the startup items need to be relocated. Pretty soon afterwards your system will boot with the same speed as before.
Continue to the chapter "Finishing the procedure" if everything went well.
Error(s) during resizing
You might see the following error after typing in the resizeVolume command:
Resizing encountered error The chosen size is not valid for the chosen filesystem (-9962) on disk disk0s2 Macintosh HD
To solve this, try to supply smaller partition sizes to the command. This error comes from the fact that you're trying to create partitions which are larger than the original volume in total.
Finishing the procedure
Setting the startup disk
First of all, you should set up the startup disk in your main Mac OS X installation. Go to System Preferences - Startup Disk and select the volume for startup:
Setting up the Startup Disk in System Preferences.
Formatting new volume(s)
Use Disk Utility to format the newly created volume(s). Select them in the tree on the left and use the Erase tab to create journalled filesystems:
Formatting the new volumes using Disk Utility.
Once you've finished formatting the new volume(s) you're ready to install Mac OS X on it they way you want.
After all said and done
I hope you enjoyed resizing your volumes and that it provides a useful starting point for dual-booting your Mac. Although the process is a bit complicated right now, Apple might provide utilities to make this easier in the future. Boot Camp already uses the same technique mentioned in this article for creating an extra Windows partition.
Maybe (and I haven't got details on this) Apple could integrate the functionality into the new version of Disk Utility for Leopard?
About this article
This article was added to the site on the 18th of August, 2006.