Like many techies, I have (and love) a TiVo. It’s a 2001 vintage DirectTiVo, and has been showing its age: the video’s been sporadically skipping for the last month, and it started rebooting late last week. It also has a lifetime subscription attached to it, which means ‘repair’ is highly preferable to ‘replace.’ It probably needed a new hard drive, which is a relatively easy operation. Just hook up the old drives in a spare PC, boot a special mfstools Linux CD, and use the included tools to backup the old disk then restore onto the new disk.
Unlike most techies, though, I don’t have a spare computer sitting around, other than a couple dead/dying/decrepit/disintegrating laptops which would need some special hardware to talk to regular IDE drives. Mfstools isn’t ported to FreeBSD (which runs this server) or MacOS X (which all our working laptops run). What to do?
From previous “rescue” operations, we had an external firewire hdd enclosure, so on a lark I mounted my TiVo ‘A’ drive in this, dd‘ed an image of it to a file, then mounted the new disk in the enclosure and dd‘ed the image on to that. Apparently this will work on some single-drive TiVos, but it fails spectacularly on a double-drive model like mine. The TiVo software doesn’t automatically “forget” about missing disks, apparently, and the box never booted in this config. For this to work, I’d need to run the proper mfstools on my Mac or FreeBSD box.
Finally last night, I figured out a virtual solution to the latter.
I’d played with qemu several times in the past. It’s a nice, free/opensource CPU emulator, and a great way to run a new/foreign OS in a sandbox. It’s how I run Windows XP on my work Linux box The virtual hard drives can be simple raw files just like the ones I was ‘dd‘ing back and forth earlier. There’s also an OS X port. Hmm…
It took a little trial and error (mostly the latter) to get right, but I was able to:
- mount the A and B disks in the external enclosure, and collect disk images with dd
- Create a new virtual disk by ‘dd‘ing 60 GB of /dev/zero to a new file.
- Start up qemu with the disk A image, disk B image, mfstools iso image, and the new empty file as disks 1, 2, 3, and 4 respectively.
- Copy all data and settings to the new drive with:
mfsbackup -Tao - /dev/hda /dev/hdb | mfsrestore -zpi /dev/hdd
- mount the new drive in the external enclosure and dd the new image onto it.
And it worked!
This was more time-consuming than it needed to be since the dds ran at about 10MB/s, but it got the TV back without needing to beg/borrow/steal an extra computer.