Cached filesystem structures, Firewire drives, and dataloss
In preparation for installing Lion, I decided to be extra-cautious and use SuperDuper! in addition to Time Machine to backup my laptop. After all, one can never be too careful with backups, as you’ll see reading on.
I have a 1.5 TB drive connected to an iBook G4 running Leopard. This machine doesn’t move anywhere, just serves as a sort of media repository / archive / SSH bounce. So the drive was filled with sundry bits of data, some more important than others, but nothing irreplaceable or critical.
So I put the iBook to sleep, unplugged the Firewire drive from it, and plugged it into my MacBook Pro. SuperDuper! worked it’s magic, I unmounted the drive, plugged it back into my iBook, woke that machine up, and thought that was that.
No. It doesn’t work that way.
As best as I can tell, sleeping the iBook did not flush the file system data structures. Whether this is a bug that’s fixed by now, or a result of any particular tweaks I may have done to the machine (though, it’s a pretty vanilla Leopard install) I don’t know. What I do know is that on resuming writes to this drive, the iBook clobbered the file system. The ~80 GB backup image wasn’t visible. So the OS used it’s cached file system structures and went on.
But the filesystem had been written to by the MBP, on unmount. So, some inodes had been modified. But the truth the iBook knew was not the truth the drive did.
Of course, the interesting part comes when the drive gets plugged back into the MBP. Files added on the iBook aren’t visible (like a considerable Linux virtual machine image I had downloaded) and the backup image is hosed, measuring about ~200k.
Joy.
Disk Utility couldn’t make anything of it, so I ended up reformatting the drive. Left myself a chunk at the beginning for backups (and this time, I can use SuperDuper! to make a bootable drive there) and the rest, well, will be filled in over time.
Moral? Always unmount your drives. This seems rhetorical, and maybe I was stupid to expect a different result in the first place. I believe it to be an oversight in implementation, though, but when it comes to your data, be paranoid.