Skip to content
accelerando

Migrate OS X to a bigger hard disk

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!

4 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 24-Jul-11 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 07-Feb-12 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 07-Feb-12 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 16-Oct-12 at 2:46 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

*

Close
E-mail It