Saturday, October 26, 2013

Upgrade to a new hard drive on your MacBook Pro and clone OSX and BootCamp



***DISCLAIMER...Its your fault if you screw up your system.  Read through the entire post before attempting.

I purchased a new larger capacity hard disk drive (hdd) to upgrade an existing smaller solid state drive (ssd) because I started running out of room.  I liked the speed of the ssd, dont get me wrong, but a weighed the options and more storage space was a priority.  So I compromised and picked up a Seagate hybrid sshd.  Got one while they were on sale $100 through newegg http://www.newegg.com/Product/Product.aspx?Item=N82E16822178340.

This one took a while to rap my fingers around and I'll say most of it was dumb luck.  I know there is WinClone available on OSX and probably would have made this easier.  Think WinClone is about $30 and honestly probably would have saved me a bunch of time, but being the stubborn ba$T@rd I am, I decide to stick through it on principle.

What I had...
OSX was 10.8
Windows was 8 with media center

Things you'll need:
  • hdd enclosure; this is to connect your existing hdd to copy data over to your new hdd
  • windows 8 installation DVD (or Win7); needed to allow bootcamp creation
  • OSX installation USB or SD drive to boot from; might be able to use the recovery instead
  • windows 7 repair CD; needed to run specific commands to fix the boot (the version of win7 repair CD I used was modified because getting the timing right to engage the CD boot process made me pull more hair out than I care to discuss.  I renamed the bootfix.bin file from the boot directory.  This causes the CD to boot instead of waiting for prompted.  The MacBook keyboard didn't work and the screen picture were out of sync to enable to proper timely to engage the CD.  You can create your own using UltraISO and renaming bootfix.bin under the boot directory.  https://dl.dropboxusercontent.com/u/92763248/Repair%20disc%20Windows%207%2064-bit.iso
  • GPART CD  http://gparted.sourceforge.net/livecd.php
  • Remove encryption.
Pre Steps:

1. With your existing OSX installation, install the gdisk program http://sourceforge.net/projects/gptfdisk/.  We will use that to modify our soon to be screwed up hybrid MBR.  In the mean time lets take a look at a none screwed up hybrid MBR.

Issue the following commands on your old OSX operating system (OS):

sudo fdisk /dev/disk0
sudo gpt -r -vv show disk0
diskutil list 


That will give us a bearing on what your disk use to look like.  Might be handy for later on to have this printed (Command + Shift + 4 than spacebar will get you to screenshot the window).

Steps:
1. Turn off the system and remove the existing hdd and install your new one (Ifixit.com is a pretty great place for these how tos).

2. Attached your old hdd to a USB enclosure and attached to your macbook.  I had purchased a simple USB3 sata link from newegg.com.



3. I made an SD OSX installation media disk. I think you could probably use the recovery hd to do the same thing.  I attached the SD to its slot.

4. I then booted the macbook holding the option key down.


5. It should boot and look like the following.  If the new hdd has no bootable partition you will not see your new drive.  The orange in color USB symbol enclosures are your old OS.  The mountain lion emblem is the OSX installation SD.  This is whether I think its possible to boot from your old OS recovery hd to perform this next action.  I haven't tried that.  The next action will be to copy your old OSX to the new hdd.  I decided to use my OSX SD and booted from that.



6. Select Disk Utility.



7. Your new hdd should be at the top.  Select it on the left pane.



8. Now select the partition drop down.  This is where we are going to partition and format your new drive.  Select 1 partition.



9. Title the new volume "new mac".  Ensure it is Mac OS Extended (Journaled) format.  Then Select options.



10. It needs to be set to GUID Partition Table.  Select OK.  Apply.



11. Partition.



12. Once completed your "new mac" partition should show on the left.  Select the Restore tab.



13. This is were we can copy our existing OSX OS to the new hdd.  Left click on your old OSX partition and hold the mouse button down as you drag it to the Source.  Notice the orange color enclosure icon.  This indicates an external device.  Now drag your newly created "new mac" partition to the Destination.  Should look just like mine. Restore.



14. Erase.




15. Should begin copying the data over.  This processes should take a while.  After that is complete reboot your macbook while holding the option key on boot.  Now boot to your new macbook OS.  I removed the old hdd and installation SD before booting.



16.  Lets see what has changed in our partitions on the new hdd.  Here is an example with the above three commands issued again.  This was on a 1TB HDD.  Notice the size in the fdisk command takes up the entire hdd.


17. We now need to partition the bootcamp slice.  Find the bootcamp icon inside the Utilities directory.
18. Start bootcamp assistant. Continue.

19. If you have a Windows 8 or 7 installation DVD remove the "Create a Windows 7..." check mark.  More than likely since this is about cloning your bootcamp Win8/7 installation you already have bootcamp installed on your Windows OS so remove the check mark.  Install your Win8/7 installation DVD and make sure the "Install Windows 7 or later version" is checked.  Continue.
20. I decide to divide my partitions equally.  You do what you want.  Install.  It is required to have the Win8/7 installation dvd installed to get this step rolling.
 21. You system will automatically reboot to DVD.  ***HOLD THE OPTION KEY DOWN WHEN THE SYSTEM AUTO REBOOTS.*** Now I have done this two different ways.  I've booted to the Windows DVD and formatted the bootcamp partition and not installed a new OS which formats it NTFS.  I've also skipped this step and booted straight to GPART CD as well.  I suspect its not necessary to format because when we use GPART to copy the old Windows OS to our new bootcamp partition it takes on the format of the copied partition anyway so why bother. I ejected the Windows installation DVD and swapped for the GPART CD and continued the boot of the CD.  With GPART booted it should show your new hdd and old hdd so long as both are still attached to your system.  If you forgot just connect and under Gparted select rescan.  Notice the far upper right drop down to select drives.  Now to distinguish which drive is which the /dev/sda is your onboard hdd and /dev/sdb should be your external.  Another way is your new hdd will say BOOTCAMP (FAT32).  Your external or old hdd should say either BOOTCAMP (NTFS) or what ever name you modified the volume name to.  Mine was Win8Pro.


22. Select your external or old hdd.


23. Select your bootcamp partition than the copy button.


24. Now change back to your new hdd and select the FAT32 BOOTCAMP partition.  The paste button should become available and select.



25. It should warn you about this action.  It should be on /dev/sda4. OK.



26. Select Apply.


27. Another warning. Apply.


28. Working.  Could take some time.




29. Once completed, reboot holding the option key and boot to OSX.  The Windows partition shouldn't appear here.  We need to modify the hybrid MBR.  You should see after booting into OSX the Windows drive and its contents though.



30. Now a decided to look at my partitions.  #1 is the EFI boot.  #2 is my OSX.  #3 is my Recovery.  #4 is Windows bootcamp.  Notice the differences in size.  The other thing I noticed was the * was on the OSX #2 and not on the Windows #4 under the fdisk command.  This is where printing out the old hdd setting is nice to see the difference.

new hdd
old hdd

 31. Time to install rEFIt. http://refit.sourceforge.net/  To install right click on the rEFIt.mpkg and open.  You might have to reboot twice for rEFIt to show.  You will notice the Windows boot icon starts to show. 


32. If you try to boot Windows right now you'll get the Recovery blue screen.



33. Reboot into OSX.  Time to make the hybrid MBR right again.  Open terminal.  Enter the following commands and see the images below.  We need to get the hybrid MBR like our old hdd.  This is how to do this.

sudo gdisk /dev/disk0
r
h
2 3 4
y
<enter>
n
<enter>
n
<enter>
y
o
w
y
sudo fdisk /dev/disk0

gdisk = allows us to modify the GUID partition.  Since Windows requires an MBR which GPTs dont use and only have them for legacy purposes we have to fix it.
r = recovery and transformation options
h = make hybrid MBR
2 3 4 (Thats the number 2 space 3 space 4 <enter>) = modifying those three partitions
y = EFI needs to be first
<enter> = select the default because thats the way our original partition was
n = the bootable flag was not set in our original
<enter> = select the default because thats the way our original partition was
n = the bootable flag was not set in our original
<enter> = select the default because thats the way our original partition was
y = because the bootable flag was set in our original
o = print protective MBR data
w = write table to disk and exit
y = confirm
34. Now your systems hybrid MBR is fixed.  Oh but wait there's more. This is where the Win7 Repair CD comes into play.  Again the only thing I modified using UltraISO was the name of the bootfix.bin file.  I renamed it "autoboot_bootfix.bin".  Insert the CD in your MAC and reboot.  Hold option and select the CD to boot from.


35. Windows repair CD should load.  It should also prompt that your Windows install is corrupt.  If you select details it will let you know what its changing.  Select Repair and reboot.  This will be quick so be fast with the option key and attempt to boot Windows now.


36. Thats it.  After booting it might ask to reboot.


37. If your not a fan of rEFIt you can always remove.  http://refit.sourceforge.net/doc/c1s3_remove.html

Hope this works for you...