Upgrading to Snow Leopard

Yes, I know Snow Leopard has been out for ages, and I did actually purchase the ‘real’ install DVD for it some time ago, but well ‘Leopard’ seemed to be working fine on my Macbook, and well I’m very cynical of these claims that ‘upgrading is easy and trouble free’. However, I bought a Hitachi 5K500.B 500GB drive recently as either an upgrade for the 160GB drive in the macbook or as a replacement for the original 80GB drive in my R60.

Given that I had a new (larger) drive. I thought I’d play with how well Time Machine and the Migration Assistant work. So as a test I setup a large mount point on a linux box and shared it out using Samba to the Macbook, then did the defaults command below to enable a samba share as a Time Machine destination:

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

I also did the mucking around with hdiutil to create the necessary sparsebundle (if you google for ‘TMShowUnsupportedNetworkVolumes hdiutil’ you’ll find a heap of references). It takes a long time to do the first backup. I then set it to ‘manual’ mode so it’s not doing continual backups. Then I did one last Time Machine backup and shut the Macbook down (running Leopard).

Now I swapped in the 500GB drive. Put in the snow leopard DVD, held down ‘c’ and let it boot up off the DVD. Then formatted the drive, and installed Snow Leopard (I picked a different account name than the one I used on my Leopard install, as Migration Assistant will complain later on if you try to restore into the account you are currently logged in as). Once I had SL installed, I then did a ‘connect to server’ in finder to mount my Samba share, then you need to click on the sparsebundle that you see, and your time machine backup should now be mounted. Now you can run ‘Migration Assistant’. Tell it you want to restore from a ‘Time Machine’ backup, then you should see your time machine backup to choose, then you get some screen with a few tick boxes and you have to wait while it says ‘Calculating’. I just left everything ticked and let it chug away restoring (it takes some time). Eventually, I just restarted, logged in as the username I used to use and voila it all looked suspiciously like my old Leopard setup.

The first thing I wanted to make sure was working was Mail. I started it up and it gives you some messages saying it needs to re-import everything and away it goes. Now, I use Mail.app as my main mail client, and I have an IMAP server that it connects to. I have some anal security in place for the IMAP server, so when Mail was restarted after the re-import I didn’t let it connect properly to the IMAP server. I then started going through my Inbox to see whether it looked OK. Everything seemed to be there, but I had a weird problem when I clicked on attachments. They would never load. There’d be some delay and then a popup highlighting there was a permission problem. This led to much trawling through Apple discussion threads and trying various things, but I could not get attachments to display. I just received that error instead

So I switched back to the original 160GB drive for a while. Then I tried again, clean format of the 500GB drive, installed SL, then this time I upgraded to 10.6.2, then did the Migration Assistant restore. No luck. Still had the same permission problem.

So by this time I was getting frustrated with Snow Leopard, so I thought I’d try to just put Leopard on the 500GB drive. Rather than use something sane like Carbon Copy Cloner or similar I thought I’d see how good a full restore from ‘Time Machine’ would go onto the 500GB drive. So with the old 160GB drive containing leopard, I did another Time Machine backup to the Samba share, shut down, swapped in the 500GB drive and booted off the Leopard install DVD that came with the macbook. Booted off the DVD, formatted the 500GB drive, then chose the option to restore from backup. This is where I learnt that the Apple install DVDs cannot mount a Samba share (or any kind of smb based share). They can mount a afp share though. So I thought, I’ll install netatalk on my Debian Lenny server that was running Samba, and just get it to share out the same mount that Samba was sharing.

This is when I discovered that the Debian Lenny version of netatalk cannot deal with encrypted passwords. Guess what OSX will only connect to? Yep, it only connects to a netatalk server that can do encrypted passwords (there is actually a defaults ‘switch’ that will allow you to connect to a netatalk user ; defaults write com.apple.AppleShareClient afp_cleartext_allow -bool true, but alas I could not get that to work from the shell environment offered on the install DVD), so then I ended up recompiling netatalk on Debian Lenny to handle encrypted passwords, which goes somehting like this;

$ sudo apt-get install libdb-dev
$ sudo apt-get install cdbs
$ sudo apt-get install libcrack2-dev
$ sudo apt-get install dh-buildinfo

$ cd debtmp
$ mkdir debtmp
$ sudo apt-get source netatalk
$ sudo apt-get install libcups2-dev
$ sudo apt-get build-dep netatalk
$ cd netatalk-2.0.3
$ sudo DEB_BUILD_OPTIONS=openssl fakeroot debian/rules binary
$ sudo dpkg -i ../netatalk_2.0.3-11+lenny1_amd64.deb

sudo afppasswd -ac
sudo afppasswd myuser

You might need to tweak some of the other files under /etc/netatalk too.

OK, so now using the notes on mounting here; I could mount my Time Machine backup from the Leopard install DVD;

mkdir /Volumes/tmachine
mount -t afp afp://username:password@server.hostname/tmachine /Volumes/tmachine

So then I kicked off my restore. Maybe 5 or 10 mins later the restore had encountered an error. I honestly can’t remember what it was. The discussion threads I found when googling for the error hinted that it has something to do with using the wrong install DVD (ie. one that came with a different Mac). I was definitely using the DVD that came with my Macbook, but I thought since I had the Snow Leopard DVD as well, then surely a full restore of a Leopard backup using the Snow Leopard boot DVD would end up with a Leopard system. So I did that, mounted the afp share OK, then started the restore … which continued just fine. Odd.

So that chugged away, and eventually I had a Leopard system on a bigger drive. I opened Mail.app, and again it said it needed to reimport Mail (just like for Snow Leopard). It chugged away for a bit, and then I had my Inbox open and it looked intact. I then found some of the messages with attachments I had had trouble with before and tried to open them. Instead of getting a permission error, I received no message at all … and in fact nothing happened (ie. my attachment still did not display). Hmmmm. Odd. It’s about now that I somehow realised that by blocking access to my IMAP server, I was preventing it from grabbing the attachment. This is probably obvious, but I imagine that Mail.app downloads attachment when you first click on them, and then caches them in the ~/Library/Mail\ Downloads directory, so that normally you’d be viewing the cached copy. However, I know that Time Machine ignores most cache directories in order to save space … so after my ‘fresh’ install plus restore, the cache directory was empty. I guess I was able to confirm my theory quickly by simply allowing my connection to my IMAP server to work (I noticed after I did this that there is a lot of activity in the ‘Activity’ window regarding caching etc.)

So after all that hoopla about Mail attachments, I thought I’ll reinstall Snow Leopard again. So same deal as before; boot off the SL DVD, format the 500GB drive, let it install SL, get it booted, perhaps upgrade to 10.6.3 or whatever, then use the Migration Assistant to restore from my Time Machine backup. This time when I ran Mail.app I let it connect to my IMAP server, and attachments worked as expected. All good

Apart from my funny Mail.app issue (which was sort of my fault), I was quite impressed with the whole Time Machine backup/restore. I am often asked by family or friends about ‘backing up their Windows PC’, and well there are a bunch of ways to back things up … but I always think a backup is only as good as your ability to restore it. My thoughts were that I could probably talk someone through doing a full restore of a Mac using a Time Machine backup … over the phone (maybe not from my convoluted AFP/Samba shared Time Machine server, but from a local USB drive). I am sure there are Windows products that claim to do something similar, but an enticing thing is that Time Machine is pretty much supported ‘out of the box’.

My upgrade was not all good. I have several vmware fusion guests on my Macbook, and when these were restored on the 500GB drive, all of them seemed to have very scary filesystem errors (the ones you get when there’s been some serious corruption). I thought maybe this was to do with Time Machine, but I ended up using my crazy rsync backups to restore from as well … and I still had the same filesystem errors. In the end, I booted back up off the 160GB drive in the macbook, and went through every Vmware guest and told them to power down (pretty much all of them were just ‘suspended’), then I did my rsync backup again, and restored them with the 500GB drive inside. And now they all work and have no filesystem errors. Obviously there is some strange inconsistency that occurs with the guest ‘state’ information during the upgrade to Snow Leopard.