Migrate OS X to a bigger hard disk

November 19, 2010 by Michael

I wanted to upgrade my 2008 MacBook (the aluminium one without firewire) with a bigger and especially faster hdd. I chose a Hitachi Travelstar 7k500. So far, it was a good choice.

This tip does only apply to an HFS+ formatted drive with a GUID partition table.

I already had a (bootable) backup that i create using SuperDuper! But for the migration purpose i wanted a bitwise copy of the old disk, so i used dd. I started the MacBook with the external drive containing the bootable backup and some space for the disk image (as i had no external SATA-USB adapter at hand. The (simple) commands for cloning (and zipping) the internal disk to an image are:

dd bs=128k if=/dev/disk0 | gzip > /path/to/image.gz

The internal disk is in most cases /dev/disk0 but it can vary. The process took about 7hours, i blame my old and slow external disk for that.

After switching the internal disk, which is irritating simple, i don’t know why Apple had to change that in the newer unibodies, i restored the image with

gzip -dc /path/to/image.gz | dd of=/dev/disk0

and rebooted.

The Mac came back immediately without a problem. If you don’t know dd you we’ll be surprised what you see: Your new disk and the partition on it has exactly the same free space as before. This is because dd does an exact bitwise copy of your disk and doesn’t resize the partition.

With the build-in OS X “Disk Utility” (“Festplattendienstprogramm”) you can easily resize the one partition (or create a second one if you like), altough you must boot from the OS X installer disk or as i did, from another bootable backup.

And there was the only problem i had. The german error message says

Partitionieren ist fehlgeschlagen

Beim Partitionieren ist folgender Fehler aufgetreten:

MediaKit meldet: Partition (Tabelle) zu klein

The english message is

Partition failed

Partition failed with the error:

MediaKit reports partition (map) too small.

Bummer. The filesystem itself is resizable but the partition table itself is not. When the original drive was formatted, the partition table was created just for that device.

I found the solution in the Life as i know blog. The author has the same problem while expanding a raid, but the solution can be used without problems for a simple drive. Note that this works only if the drive has just one partition on it! If you try this on your own, i’m not responsible for any dataloss.

Just use the following commands in a terminal (replace /dev/disk0 with your device) (the device must not be mounted while using the commands, therefor like stated above, boot from the installer disk or a backup):

sudo gpt show /dev/disk0
This shows the current partition table. Note the number in the column “SIZE” with the highest value.
Unmount the disk through Disk Utility
The Partitiontable cannot be changed when the drive is mounted.
sudo gpt destroy /dev/disk0
This destroys the current partition table, so be carefull.
sudo gpt create -f /dev/disk0
This creates a new partition table with the correct size for your new harddrive
sudo gpt add -b 409640 -s XXX /dev/disk0
Replace the XXX with the value from size in the first step.
Use Diskutility to mount the disk again. You now can resize the partition or add another
Eventually you need to reboot, but in my case it wasn’t necessary, the partition showed up immediatly. I hower did reboot after resizing it to see, wether the cloning did work.

The cloning did work and i now have a much faster system and more space available.

You can use the process of destroying and recreating the partition table for drives with more than one partition, you must repeat the gpt add step and change the start and end parameter correctly.

Please be sure what you do, when you try to repeat the tipps in this post!

5 comments

  1. eric@ericwade.com wrote:

    If you receive an error or alert after this process after rebooting back from the HDD specifying “Partition map check failed because no slices were found” then don’t panic.
    Simply reboot to the installation disk and run the Repair Disk from there to restore the slices.

    Posted on July 24, 2011 at 9:01 AM | Permalink
  2. Nividica wrote:

    Thank you very much for sharing this. After upgrading my hdd I found myself with this little issue.
    I also wanted to add a couple of notes about my experience, as I booted from the installation disc. I ran into an issue with the gpt commands.
    #1) Sudo doesn’t exist, so everything runs with su privileges (not really reading the error can lead you(me) to believe you typed it in wrong, and thus typing in the wrong command 4 times in a row)
    #2) For reasons I can’t even begin to understand, after any command in the terminal, besides umount, my partition was re-mounted automatically. (Ran in circles for a while with this one)

    So my ending commands were:
    umount /dev/disks02
    gpt show /dev/disk0
    umount /dev/disk02
    gpt destroy /dev/disk0
    gpt create -f /dev/disk0
    gpt add -b 409640 -s XXX /dev/disk0

    Posted on February 7, 2012 at 7:33 AM | Permalink
  3. Michael wrote:

    Thanks for your feedback.

    I booted from a backup so I had sudo. Don’t know why it isn’t on the install disc.

    Have a nice day!

    Posted on February 7, 2012 at 7:40 AM | Permalink
  4. lantianer wrote:

    Thanks! Worked perfectly for me on a sparsebundle. Creating a second Time Machine backup for my Mac (to keep off-site), but the new drive is bigger so I wanted to expand my backup image. Time Machine seems to be working fine with both drives.

    Posted on October 16, 2012 at 2:46 AM | Permalink
  5. selbstdenker wrote:

    Thanks your idea is great !

    Simpler solution in brief:
    1) download GParted-Live CD from http://www.gparted.org/download.php
    2) boot from this CD
    3) accept the suggestion to enable the full disk
    4) reboot from mac OSX
    5) try again – now it works

    Long version:
    1) the only problem is the disk header which exists twice: at the beginning and at the end of of the disk. Somehow Mac OSX shows the real disk size, but is not capable to change the GPT size header and to relocate the second “header” to the real disk end.
    2) While booting you may hold down keys with different effects. http://support.apple.com/kb/HT1343 Pressing the Option-Key leads you to the boot selector. If you have attached a PC keyboard you may expect to use the “Windows”-Key. In my case I had to use the “Alt”-Key.
    3) EFI-Boot failed, while Windows-Boot from the CD (those guys mean X Windows not MS-Windows) worked well. I have chosen all default options for my Mac Mini 2009. When booted a pop request offered me to extend the GPT size. I accepted and
    4) rebooted.
    5) I went on with the harddisk utility under Mac OSX and succeeded this time.

    I would say, this avoids miscalculations and other mistakes, as they might happen with your recommendation.

    Posted on September 5, 2014 at 4:36 PM | Permalink
4 Trackbacks/Pingbacks
  1. […] Also migrating systems on Macs has always been easy. The user account on this machine is basically the same as 12 years ago: It’s been migrated from an iBook to an G5 iMac to several MacBooks and onto this Intel iMac. This time i didn’t use dd for migrating the data but Carbon Copy Cloner, as i didn’t want to work on the partition table again. […]

  2. Resizing HFS+ volume after cloning - PhotoLens on November 15, 2021 at 7:51 AM

    […] The correct and safest solution, with explanation, is from this comment. […]

  3. […] to reflect the new hard disk size. Run gpt tool from terminal as described in this post (see also this), destroy the existing partition table and recreate a new one with the correct partition […]

  4. […] to reflect the new hard disk size. Run gpt tool from terminal as described in this post (see also this), destroy the existing partition table and recreate a new one with the correct partition […]

Post a Comment

Your email is never published. We need your name and email address only for verifying a legitimate comment. For more information, a copy of your saved data or a request to delete any data under this address, please send a short notice to michael@simons.ac from the address you used to comment on this entry.
By entering and submitting a comment, wether with or without name or email address, you'll agree that all data you have entered including your IP address will be checked and stored for a limited time by Automattic Inc., 60 29th Street #343, San Francisco, CA 94110-4929, USA. only for the purpose of avoiding spam. You can deny further storage of your data by sending an email to support@wordpress.com, with subject “Deletion of Data stored by Akismet”.
Required fields are marked *