Wednesday, August 21, 2013

Macbook new disk and unable to resize partition to take advantage of new space

I ran into a problem with a macbook after cloning a hard drive and the partition would not resize to take advantage of new space.The following blog helped me solve the issue.

Thanks to:

http://blog.kyodium.net/2010/11/increase-disk-and-partition-size-in.html?showComment=1376667624476

This is because the GUID partition table (GPT) is built for the size of the drive it's created on. And that's a pretty logical assumption... until you consider RAID, or virtual disks.

All we need to do is remove the GPT and rebuild it. We're not deleting the actual partition, so as long as you remember the start and size information for the partition you should be able to back-track if things get messy. I have been successful with this technique, but as always when dealing with important data - try to back up before you proceed!

Boot from your Leopard DVD

Open Utilities - Terminal...

Find the disk you want to expand (mine was /dev/disk1s1, we'll use this as an example from now on):
df




Unmount the disk
umount /dev/disk1s1

Display GPT info for the disk:
gpt show /dev/disk1
NOTE: we remove the slice number from the name (disk1s1 becomes disk1)


Note down the numbers for start and size for your partition.

Unmount the disk again.
umount /dev/disk1s1

Remove the GPT:
gpt destroy /dev/disk1

Create a new (empty) GPT:
gpt create -f /dev/disk1

Add a new entry for our disk to the GPT:
gpt add -b -s /dev/disk1

so in my case the command would be:
gpt add -b 409640 -s 41009112 /dev/disk1



Reboot. Now you can use Disk Utility to resize your partition without errors.