Tuesday, October 9, 2012

Swapping in an SSD for an HDD

Following this blog post and a great SSD from Other World Computing, I was able to install an SSD into my Macbook Pro, giving it new life, boosting its speed and expanding its storage space.  In addition, OWC sells a CD frame replacement in which your old HDD can be installed. This is great, however, it creates a complex situation.  Your HDD needs to be copied to your SSD and that means either going through an external drive (USB case), and that can run slowly, or you can build your Macbook Pro up with the new drive configuration and get it all done at once.

Being a bit adventurous and wishing to make the fewest copies possible, I elected for the latter. Of course, this created more work for me because of some difficulties I ran into, but I learned a little bit about unix drives and UUIDs.

If you're going to change your Mac's HDD to an SSD and move your HDD into the CD drive bay, here's how to do it:

  1. Backup your Computer
  2. Hardware Change
    Follow breakdown and installation instructions for SSD swap for HDD and HDD placement in the CD bay. NOTE: (if most Macbooks are similar) your HDD has two pairs of stubby bolts that hold it in position in the main drive bay. Be sure to remove them and move them to the SSD. Put the HDD into the CD replacement frame and install both the HDD and the SSD.
  3. Boot to Single User Mode
    When you power up the Mac, hold down the Option key until the screen displays a choice of drives from which to boot. Before selecting the drive, hold down COMMAND-S. Continue to hold down CMD-S while selecting the drive. This puts the computer in single user mode and makes the HDD read only. You're about to copy that drive, you don't want a lot of extraneous processes running and modifying the filesystem. Even better, read only prevents changes to the drive. Try running "ps -elf" and you should see only a couple of processes.
  4. Copy the Drive
    Follow the instructions at link above for copying the drive. Note: author makes a comment about not copying empty drive space (0s for HDD v. 1s for SSD being important). I don't know how important this is.
    Be sure you know which drive is which. Most likely, you HDD is /dev/disk1 and your SSD is /dev/disk0. This has everything to do with which hardware SATA link they are connected to and not which drive was used for booting the OS (first, mount the drive, then read it, then boot the OS, so /dev/disk* order is deterministic).
    Copy command looks like: dd if=/dev/disk1 bs=1024 count=### of=/dev/disk0
  5. Change UUID
    At this point, the drive is an exact copy, which creates a problem. If you reboot now, your machine will not work. Both drives look exactly the same to the system because of the shared UUIDs. Using hsf.util, change the UUIDs on the new SSD (there are most likely two of them) before reboot. This program lives in /System/Library/Filesystems/hfs.fs/.
    hsf.util -k rdisk0s2 ## Shows UUID for rdisk0s2, if it has one.
    hsf.util -s rdisk0s2 ## Generates new UUID for rdisk0s2.
  6. Reboot
That's it. You should be done. Leave your machine in this configuration for a week or so until you decide that you're happy with the new hardware configuration and the system feels stable. If you plan carefully and you still have Snow Leopard on your machine, you can leave your HDD with Snow Leopard and install Lion or Mountain Lion on the SSD. Then, you can dual boot your Mac using both drives, with Mountain Lion being your preferred OS and Snow Leopard your occasional.

Why do this? You might have many reasons, like certain applications that work only on Snow Leopard. If you're building OSX ARC applications and you want to debug that ARC app on Snow Leopard, either you need a second machine (running 10.6.8) or you can boot your Macbook off of the second drive.

Good luck with your hardware upgrades.

PS: I also received great help from superuser exchange.