September 30, 2014

Brain Transplant on a Macbook Air

I recently “upgraded” to a new Macbook Air: went from a 2013 to a 2014 model. As far as upgrades go, it’s not huge: I doubled the SSD size (from 128GB to 256GB) and got a slightly better battery (see specs for all models here). I don’t normally upgrade my hardware every year, but the opportunity was there.

Usually, I dread changing machines, since it’s a huge PITA, especially with dev machines (from past experience, anyway). This time, however, OS/X offered me a pleasant surprise: the Migration Assistant. Although I couldn’t get it working over WiFi, it was still a relatively straightforward process:

  1. Back up old machine to a USB drive using Time Machine
  2. Restore new machine from the backup on the USB drive

That’s pretty much it. It moved almost everything:

  • Documents
  • Applications (both those installed through the AppStore and otherwise)
  • User accounts
  • Databases (I had MongoDB installed for some of my projects)

Several apps like MS Office and Amplitube worked fine, but asked for a product key on start-up. As far as the Migration Assistant goes, I guess that’s fair enough - the applications are running on completely different hardware.

I did run into a couple of hiccups, though. A couple of homebrew packages refused to work:

bash: mongod: command not found
bash-3.2$ brew install mongo
Error: mongodb-2.6.0_1 already installed
To install this version, first `brew unlink mongodb'

Luckily, getting them back is fairly simple:

bash-3.2$ brew unlink mongodb && brew link mongodb
Unlinking /usr/local/Cellar/mongodb/2.6.0_1... 0 symlinks removed
Linking /usr/local/Cellar/mongodb/2.6.0_1... 14 symlinks created
bash-3.2$ mongod

Here’s a list of packages that I had do treat manually:

  • autojump
  • mongodb
  • python

I ran into some more problems with Python:

bash-3.2$ pip install nose
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 139, in <module>
  globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
  raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.

Luckily, I wasn’t the first to experience something like this, so a solution was only a Google query away:

brew install openssl
brew link openssl --force
brew uninstall python
brew install python --with-brewed-openssl

Finally, you have to be a bit careful with your git repositories after restoring from a backup. TimeMachine and git don’t play well together, meaning the integrity of the repository in the backup cannot be guaranteed. If there’s a copy of your repositories off-site (there should be!), then it isn’t a huge deal - just pull from the off-site repository and you’re done.

And that’s about it. Time-wise, the whole endeavor only took several hours (most of which was I/O time that I wasn’t even around for). If reading about other people’s experiences with restoring from backups is your cup of tea, then have a read of this - it was the starting point for this blog post.