Expanding RAID & RAID Partitions on Mac

I have a Mac OS X 10.6 Snow Leopard server that I manage. We have it connected via iSCSI to a SNAPServer SAN disk array (RAID-6). The beauty of RAID 6 and the GUID format of the drives is that we can resize a volume on the fly…sort of. On the Mac, you can resize partitions but because of the way partitions are handled, you may get an error from Disk Utility. The below procedure works without destroying data. That being said, please read the IMPORTANT NOTE below:

IMPORTANT NOTE: The following procedures are ONLY for people with RAID cards who have upsized their raid array. If you have a MacBook or MacBook Pro, this is not for you! If you want to move from a smaller single drive to a larger single drive, try CarbonCopyCloner or SuperDuper .Once my raid array had finished upsizing from 5.5GB to 9.1GB, I had to resize the partition in order to actually use the space. OS X’s Disk Utility gives the cryptic error

(Partition failed with the error: MediaKit reports partition (map) too small. ) Not particularly helpful, is it. All my googling has never found an answer, so I thought I’d post my solution here. Before you start, BACKUP YOUR DATA. While I have not lost data using this procedure, if you make a typo, the results could be catastrophic!

Open up a terminal

type df and press enter

Note the mount point for the drive you’re trying to expand. Mine was “/dev/disk4s1″. We’re only interested in the disk, not the slice, so I’m going to use “/dev/disk4″.

In Disk Utility, unmount the current partition on the disk.

run “sudo gpt show /dev/disk4″. If this fails, you probably didn’t unmount the partition first.

The line with the largest size is the partition we care about. Write down the start and size numbers. Check them again to be sure you wrote them down correctly!

In Disk Utility, unmount the partition again.

run “sudo gpt destroy /dev/disk4″

run “sudo gpt create -f /dev/disk4″

run “sudo gpt add -b 409640 -s 11719262168 /dev/disk4″. Notice those numbers came from the start and length of the partition we want to save.

Reboot. (On a Snow Leopard server I did not need to reboot!)

Now use Disk Utility to resize the partition. If you didn’t reboot, Disk Utility will probably give an error, but it might still work. Reboot now anyways.

Basically what’s going on here is that the GPT table is built only big enough for the drive it’s on. That’s a logical assumption – hard drives don’t magically get larger – unless they’re RAID arrays. We’re just removing the GPT partition information, and replacing it. Should things go crazy, as long as you’ve got the start and size information for the partition you care about, you should be good. No guarantees obviously, but I’ve done this three times and no data loss yet.