Mac OS X HFS+ Whole Drive Backup and Restore Onto a Larger Disk

The goal was to transfer 120 Gb image of whole system onto new 250 Gb hard drive without reinstalling the OS.

Why problematic?

After transfer GPT will not know that You have larger disk now and will not allow You to add partitions or grow existing ones using new free space.

There are no free tools, which allow You to grow HFS+ partitions. (From the shareware iPartition should be able to do that, but I have not tried)

We will need

Additional hard drive, where we will hold our system image

Ubuntu LiveCD (or any other thing, which will allow us to run gdisk on it)

Internet connection

optional Ubuntu LiveCD can be easily transformed into LiveUSB, which allow to save data on it and it’s performance is better

Boot from LiveCD

Insert USB flash drive

unmount it

System -> Administration -> USB Startup Disk Creator

optional Install dcfldd tool. (You can use dd instead with absolutely same parameters, but i like dcfldd, because it shows the progress.)

System -> Administration -> Package sources

Ensure that “universe” is checked

$sudo apt-get update

$sudo apt-get install dcfldd

Crate image from of source system

$sudo dcfldd if=/dev/sda of=/media/DISK/MySystem.img bs=4194304/dev/sda is the disk you want to make image of
/media/DISK/MySystem.img file where system image will be saved
4194304 is block size, I set it to 4 Mb to speed up the process

Prepare the destination disk

It should be empty before we start, I used GParted from the Ubuntu LiveCD (System -> Administration -> GParted).

Just delete all partitions, if it is not empty yet, all the space should be unallocated.

Copy image to the new disk

$sudo dcfldd if=/media/DISK/MySystem.img of=/dev/sda bs=4194304/dev/sda is the disk you want to put image to
/media/DISK/MySystem.img file where system image was saved
4194304 is block size, I set it to 4 Mb to speed up the process

Install gdisk tool

$sudo apt-get install gdisk

If it is not in the repository, find the .deb from the web and install it manually ($sudo dpkg -i package_name.deb)

Update GPT table on the disk

I assume You have one partition on the source disk.

$sudo gdisk /dev/sda

i – it will prompt for partition to get info about

1 – the first partition on the disk should be ‘EFI System’, remember start block, end block and type

i

2 – perform these steps for each partition you have on the source disk and remember their start and end blocks and partition types

After You got info about all partition you are ready to flush GPT.

o

Y

Now we have to recreate all partitions, which were on the disk and add our additional 130 Gb space as new partition

n – now you must enter start block, end block and the type of the new partition you are going to create

the start block number you got while reading info about 1st partition

the end block number you got while reading info about 1st partitionEF00 (if first partition was EFI)

It’s not necessary to delete and re-create all the partitions in gdisk; just use the ‘e’ option on the experts’ menu to relocate the backup GPT data structures to the end of the disk. You can then add more partitions or resize the last one using other tools (GNU Parted, OS X’s Disk Utility, etc.). GNU Parted does this automatically, if you prefer to use it.