So I Wrecked A VM
- 2 minutes read - 364 wordsAt home, I use VirtualBox as my preferred VM solution. It’s been taken over by Oracle, so I’m hoping that they keep it on. It’s one of very few solutions that’s OS X native, and performs quite well. I keep a couple of Linux VMs handy, because there’s a few things that are easier to do on a Linux VM than natively. For instance, Imagemagick is a pain to install on OS X, but is a one-hit install on Linux.
This has worked fine for a while. OK, I’ve had some problems, but nothing too serious. There’s a few tricks: always install the ‘build-essential’ package, and make sure that you keep the VBox Additions matched to the VirtualBox build you’re running.
But a couple of weeks ago, disaster struck — VirtualBox barfed violently on my VDI file. It’s dead. There’s comprehensive discussions at the forum, but none of them cover the problem I’m having. Bye-bye carefully-crafted environment and quite a lot of data and scripts to process the data.
Now, I know, “restore from backup”. There’s only one slight difficulty: Time Machine does not get on with VM disk files. Not at all. Essentially, it sees one mammoth file, which changes all the time, and so it dutifully keeps copying the whole file, until it burns through all of the space on the backup volume. So that’s out of the question. So, what to do? Turns out there’s a command to do this:
VBoxManage clonehd ...This does not work if your file is damaged. Panic!
But wait… enter, stage left, PhotoRec, clutching glad tidings of happiness and joy to its chest. It’s meant for recovering wrecked SD cards, but it works on any file… including a damaged VirtualBox disk image file.
I’ve run it on a test VM so far, and what I’ve got back is horrible, but I’ve got data back. It’s found 108038 files in the test VDI file, and it’s sorting them into folders. There’s probably more to do, but it’s not so bad.
For the future, I’m going to write startup/shutdown scripts that damn well back up the disk image files, so this shouldn’t happen again. I hope.