05 Jan 2005

repartitioning in osx

partitioning tools are generally sucky on the mac. the default one that apple supplies is Disk Utility, but the problem with that is that you cannot repartition, only completely wipe out the partition table and redo it.

so you are left with either iPartition (shareware), GNU parted (open source) or mac-fdisk (open source). i didn't try iPartition because i'm cheap and i won't fork out $30 for something that i will only use once and never again. GNU parted is a powerful (but dangerous) partitioning tool that work on PPC linux in console mode. i say dangerous because you can't revert changes. once you hit that "d" button, thats the end of your partition. mac-fdisk is the only reasonable tool i found because the interface was very similar to regular fdisk on x86.

so i just repartitioned my powerbook to get rid of 2 redundant partitions on my mac and use HFS+ all the way. first thing you do is backup, i practically backed up everything. if you're from the UNIX world, then be careful that rsync/tar/cp etc doesn't deal with resource forks (metadata in the filesystem). so the best way is to use metadata-aware psync (from MacOSX::File perl module available on CPAN.) i used a combination of psync and tar + netcat to move data to either my external hard disk or another networked machine.

the next thing to do is grab a Gentoo Linux PPC LiveCD. i grabbed the 2004.3 minimal PPC LiveCD and booted off it by holding down the option button when booting. once on the console of the LiveCD, you can use both parted and mac-fdisk. then it is just a matter of deleting all the partitions that are useless. be careful with deleting the Apple_Boot partitions that seem to be associated with all bootable partitions. i deleted mine on the secondary partition and lost the ability to boot from it. also, make sure you get the partition types right, Apple_HFS is the default partition type, and using mac-fdisk, you have to use 'C' to be able to specify the partition type.

once that is all done and you've committed the changes, that is it. reboot back into macosx and then run disk utility to re-format the filesystem to take advantage of the extra space. note that if the start of the partition has stayed constant, HFS+ won't complain about the resized partition and will just continue using the filesystem in its regular size. maybe there are tools (eg. iPartition) to resize the filesystem as well. i didn't find any open source tools that did that, but i didn't look very hard.

so that is just a quick summary of how one would do some repartitioning on a mac. of course, there is no real reason to do partitions only if you are worried about re-installing. the always had two partitions because if i were ever to reinstall my mac, i could just dump my home directory on the other partition and do a clean install. but if you have an external harddisk, then you can use that instead. finally, it is interesting that the only real useful partitioning tools is actually off a Gentoo Linux LiveCD.

You can reply to me about this on Twitter: