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
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!