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

 

  1. optional Ubuntu LiveCD can be easily transformed into LiveUSB, which allow to save data on it and it’s performance is better
    1. Boot from LiveCD
    2. Insert USB flash drive
    3. unmount it
    4. System -> Administration -> USB Startup Disk Creator
  2. optional Install dcfldd tool. (You can use dd instead with absolutely same parameters, but i like dcfldd, because it shows the progress.)
    1. System -> Administration -> Package sources
    2. Ensure that “universe” is checked
    3. $sudo apt-get update
    4. $sudo apt-get install dcfldd
  3. Crate image from of source system
    1. $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
  4. Prepare the destination disk
    1. It should be empty before we start, I used GParted from the Ubuntu LiveCD (System -> Administration -> GParted).
    2. Just delete all partitions, if it is not empty yet, all the space should be unallocated.
  5. Copy image to the new disk
    1. $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
  6. Install gdisk tool
    1. $sudo apt-get install gdisk
    2. If it is not in the repository, find the .deb from the web and install it manually ($sudo dpkg -i package_name.deb)
  7. Update GPT table on the disk
    1. I assume You have one partition on the source disk.
    2. $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
    3. After You got info about all partition you are ready to flush GPT.
      • o
      • Y
    4. 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 partition
        EF00 (if first partition was EFI)
      • n – next one
      • the start block number you got while reading info about 2nd partition
      • the end block number you got while reading info about 2nd partition
      • AF00 (if second partition was HFS/HFS+)
      • And so on for every partition you have
      • n – adding the last one
      • [Enter] default
      • [Enter] default
      • AF00
    5. Write changes to the disk and exit
      • w
  8. The last step: merging partitins
    1. Reboot into Mac OS X
    2. diskutil mergePartitions “Journaled HFS+” NAME disk0s2 disk0s3 (in my case: append disk0s3 to disk0s2). Please note, that data on the disk0s2 will stay intact.
  9. Now you should have absolutely same system as you had before the transfer, but on a larger partition.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>