Saturday, 6 October 2012

Upgrading Macbook hard disk and restoring its Partitions

When I bought my Macbook aluminum in late 2008, it came with a 250 GB hard disk and pre-loaded with Leopard. I later upgraded the OSX to Snow Leopard in 2009 and continued using it until a couple of months back when I needed to upgrade the hard disk due to it running low on disk space. During the three years, I partitioned the Macbook for using Windows 7 and Ubuntu (a linux variant) 11.10. My other post gives details on how to Triple boot a Macbook.

I decided to upgrade the original Macbook's hard disk to a 1TB one, which I reckon would give it a fresh lease of life and keep it running for atleast a few more years. For that, I chose Samsung Spinpoint M8 SATA II. Samsung has sold its HDD business to Seagate in 2011 and it is likely that this particular model might be in short supply.

Step 1. Things required for changing the Hard DiskThe actual process of changing out the hard disk is a fairly straight forward process. Page 41 of the  manual from Apple' website tells you how exactly to go about the business of changing out the hard disk. One however would need, (1) a TORX T6 screwdriver, (2) a Phillips screw driver and (3) an Antistatic wrist strap to do the business. It is also advisable to keep the removed hard disk in an external enclosure and use it for storage once you are sure that the upgrade process is complete. For a 2.5" USB 2.0 IDE HDD enclosure, I bought one produced by IOMAX from Amazon, which is cheap and reliable.

Step 2. Things to do before changing the Hard Disk
I would however advise against replacing the hard disk until a few things are sorted out. It is best to have an external hard disk of atleast 250 GB to store backups of the hard disk that is being replaced.

(i) For Mac OSX, download a software called Carbon Copy Cloner. A trial version (for one month) is available, which gives ample time to do the entire Mac partition cloning. The Mac OSX cloning is very straight forward and the interface resembles that of file transfer, wherein the files are simply copied from one disk to another. In my case I bought the software as I ran into numerous troubles, partly because of the update to OSX Mountain Lion.

(ii) For Windows, the advise online was to use Winclone, which I had no success, probably because one needs an external disk to store the image file and also the Windows partition should be a Bootcamp partition. I used Paragon backup and recovery 2012 free edition, which I found to be very user friendly.  You can register to get a free code for home use.

(iii) For Ubuntu, one could either use Paragon backup and recovery or dd utility in Ubuntu or Clonezilla. I used Paragon, but I needed to reinstall grub to make the partition bootable. To reinstall grub, one need to have an Ubuntu Live CD/DVD handy.

A screenshot of Paragon backup screen is as below (this is a screenshot of not my original hard disk but the new hard disk which I am backing up):

Step 3. Cloning Mac OSX
Next stage is to place the new hard disk into the HDD enclosure. Don't worry, once the disk is Partitioned and the Mac OSX cloned, we can go ahead with the next phase of restoring the Windows and Ubuntu partitions by installing the new hard disk in the Macbook.

Boot into OSX and connect the new hard disk in the enclosure to the USB port. OSX would immediately detect it and mount it. Go to Disk Utility and Partition the new hard disk. In my case, I partitioned into three partitions, (1) 400 GB for Mac, (2) 200 GB for Ubuntu and (3) 400 GB for Windows7.

Format the Mac Partition into HFS+ Journaled, Ubuntu into FAT32 and Windows into NTFS. In my original Macbook hard disk, I used Bootcamp to create the Windows Partition. However, as we don't intend to do a fresh installation, Bootcamp wouldn't be appropriate for use.

Use Carbon Copy Cloner downloaded, to start the process of copying. The screenshot below gives the Carbon Copy Cloner screen in operation. In the Select a source, select the Mac partition that we wish to copy and in the Select a destination, select the External hard disk location. Once you say clone, the process would start, which would take an hour or two depending the size of the partition.

Once the cloning part is completed, your Mac part of the hard disk is ready for use. If you install an application named rEFit, you can indeed boot using the external disk as well.

Step 4. Restoring Windows 7 and Ubuntu
As mentioned in Step2, you need to download Paragon Backup and Recovery 2012 to enable to restore Windows 7 and Ubuntu. For that you need to boot into the Windows7 and when you are ready to go,  connect the spare 250 GB external hard disk (formatted in NTFS) to able to Backup the complete partitions of Windows 7 and Ubuntu onto this drive. Paragon compresses the Archive file and stores them into a format that is easy to restore. At this point you have two options, (1) To create a Paragon boot disk, which will enable you to boot into Paragon Backup and Recovery Menu and thereafter go with the restore process or  (2) continue in Paragon Backup and Recovery application in Windows7 and do the process of restoring.  

Once the backup is done, start the restore process. For that you need to have both the New hard disk in an enclosure and the external hard disk connected. Select the location of the archive backup (on the external hard disk) and restore it to the partition created (on the New hard disk in enclosure). It is best to do them one by one (Windows 7 first and Ubuntu next), so that you don't get mixed up with the partitions. Once the restoring process is complete, you are technically ready to go. During the restore process using Paragon don't forget to choose the option of restoring to the complete partition. Or else you will end up with two partitions, one the same size as the original partition and the other an unallocated partition. This is likely to happen with the Windows7 partition, even though you select the option of filling the entire partition. You can boot into Windows7 and fix that, which is easy. Restore the Ubuntu partition as well, following the same steps as for Windows7.

Step 5. Replacing the hard disk
Now the moment of truth will arrive. You are ready to swap the hard disks. Take the one in the enclosure and place it in the Macbook. Follow Step 1 Page 41 of the Macbook manual and replace the hard disk. Place the old disk in the enclosure and keep it aside until you are sure that the entire process of Upgrading the hard disk is completed without any further hitches.

Step 6. Starting Windows 7
The only problem you could face is Windows7 wouldn't boot. For that pop in your original Windows 7 DVD and choose the Repair the Installation option and thereafter follow the instructions in my previous blog post of repairing the Windows7 MBR.

To expand the Windows 7 partition, download the Minitool Partition Wizard. That will leave with a small problem with the Mac GPT partition table and MBR partition table being out of sync. You can fix that later, if you find that to be disconcerting.

Step 7. Starting Ubuntu 
For Ubuntu, you might run into the problem of the Grub not being recognised. This part is a bit tricky. It would require you to pop in the Ubuntu Live CD and go into the Live CD mode. Then do the following instructions in Terminal:

(i) sudo fdisk -l

Note down the partition of your hard disk onto which the Ubuntu has been restored. It could be /dev/sda3

(ii) sudo grub-install /dev/sda3

Assuming Ubuntu partition is 3. This should work, but if you run into problems, you might have to use the chroot method.

When you use the chroot method, don't forget to update the installation.

Step 8. Syncing of GPT and MBR partition tables
For all practical purposes, do not disturb the MBR partition table. Just note the Windows7 Partition block size (start and the end sizes) in Minitool Partition Wizard. Boot into Mac and download iPartition. Unfortunately, iPartition is not a free application. However, it did what it need to do to the GPT partition table, which the Mac OSX uses and it completely saved my day and all the hard work I did on trying to sync the GPT and MBR partition tables. Here is a screenshot....

However, to use iPartition, you need to boot into another installation of Mac OSX as it can't be used on the same hard disk as the one on which the application is located. For that you could use the Mac OSX installation in the external disk (the old installation). To boot into the external hard disk installation, you need to install rEFIt, as it is the only way you could detect the installation on reboot. Whilst using iPartition, take special care whilst sizing the Windows partition. Sometimes, it could overlap over the other partitions, like say Ubuntu. Once the resizing of the Partition is done using the data you noted from MiniTool, you are more or less done. Use Partition Inspector, which is installed as a part of rEFIt to check whether the GPT partition tables and MBR partition tables are synced. A sceenshot of Partition Inspector is provided below.

You can see that the Partition tables are completely synced. Don't worry that the MBR counts from 1, while GPT counts from 40. Everything is perfectly in order. Now you are ready to go.


As usual there are lessons learnt in everything you do for the first time. In this particular instance, the scenario was quite nightmarish because of my reluctance to really dive into OSX side of the Macbook that much. I tended to use Windows 7 and Ubuntu partitions for most of the time and wasn't really familiar with GPT partition and how it works and what problems one might face when doing partitions. I probably was trying to do too many things simultaneously. For the first instance, I tried to restore the Mac OSX partition first and then dived right into upgrading from Snow Leopard to Mountain Lion. As a result, there was a situation with Mountain Lion creating a Recovery HD partition, which messed up the boot partition tables and MBR wouldn't recognise Windows7 partition. Eventually the method suggested by Chris Murphy really worked.

I eventually botched the entire hard disk, whilst using Gparted to resize the partition of Windows7. I had to restart from Scratch, including re-downloading Mountain Lion. In the second instance, I didn't scale down the Mac partition by 700MB, as a result I couldn't get the Mountain Lion Recovery HD partition installed. In a way, it is ok, because I am backing up the Mac Partition using Carbon Copy Cloner, instead of using Time Machine. It is easy and I have a complete installation ready to use, unlike Time Machine. In one particular instance, I had the File Vault option turned on, as a result, Time Machine, didn't really backup my Home folder. Thank goodness that I kept the original hard drive in an external enclosure and that saved the day for me.

Following the restore of Windows7 partition, it now appears that Mac OSX wouldn't mount Windows7. I had to device a workaround for that, which I will cover in a new post.

No comments: