Intro

ET OSX is a list of useful tools for the MacOS X, most of which live in the Applications folder on my startup drive. It started as a 'what's on my Mac' page on my personal site but quickly evolved into a blog of its own. I'm trying to focus most on of the tiny but useful utilities that sometimes save you lots of trouble and effort, and to omit for the most part the list of big guns, that one normally uses on a daily basis. The list serves two purposes, lets me easily answer 'how do I do this on the Mac' questions asked by other users, and helps me remember answers to the same questions myself.

Live re-partitioning, unix style

Since Mac OS X 10.4.6 the built-in diskutil tool (Disk Utility.app's CLI brother) supports live repartitioning of the boot volume. The feature became very popular with different macos x related forums because of Bootcamp Assitant which first introduced it. In short words it allows you to reformat your Mac's built in hard drive without loosing your data. If you don't fear the command line interface, here's how to do it:
-Launch Disk Utility.app to find your boot volume's disk identifier - select it from the list of volumes to the left, then click on the (I)nfo icon on top. It should be something like 'disk0s3'
- Fire-up Terminal.app and issue the following command:


sudo diskutil resizeVolume disk0s3 limits

which will give you info how big your volume can grow or shrink to
!!! Important !!! When creating new partitions make sure you have enough free space on your drive to accomodate them (makes sense)
now decide upon the number of new partitions you need to create and what their format will be. Create them with:
sudo diskutil resizeVolume volumeName newPartitionFormat newPartitionName newPartitionSize, i.e.

sudo diskutil resizeVolume disk0s3 JHFS+ Tiger 30G JHFS+ Backup 20G

which will add 2 more partitions next to my existing volume, first one named Tiger (30Gigs in size and formated as Journaled HFS+) second one named Backup (20GB, again Journaled HFS+). After resizing the volume diskutil will ask you to restart and you will then need to erase the newly created partitions, using either diskutil (diskutil eraseVolume) or Disk Utility.app.
Update: the diskutil resizeVolume command unfortunately supports only GUID Partition Tables. PPC Macs can not boot from GPT formated disks, so I'm afraid live resizing is off limits to them. Good news is that if your drive was formated as Apple Partition Map or Master Boot Record you still don't have to re-format it. You can use BootCamp assistant to create a 'Windows' partition which will do the job for you.

4 comments:

Anonymous said...

Unfortunately, this only works on Intel Macs.
For example, running
sudo diskutil resizeVolume disk0s3 limits
on a PPC-based Mac you'll get the following error:

Error obtaining resizing information

Resizing encountered error Could not modify partition map (-9986) on disk disk0s3 Macintosh HD

djidji said...

My bad, I missed to point that the resizeVolume command only works for GUID Partition Tables, which PPC Macs can not boot from.

The Street Corner Philosopher said...

Hmmm... i've read the post and the comments associated with it and I am not sure whether my own question applies. I'm using OS 10.4.1. The disk I want to resize while keeping the data in it intact is NOT the boot disk, it's an auxiliary one. Would this fact alter the information given above?
How can I create partitions on the free space of this auxiliary hard disk?
Thanks for letting me know.

djidji said...

@Sergio, there won't be any change in behavior whether you use the above on boot or non-boot volumes. If you don't feel secure I'd suggest you do a quick experiment though - say on a usb flash stick. Unfortunately I can't replicate the situation immediately, 10.4.1 now seems so long ago :-)