Ever been in this situation? Something goes wrong with your host machine while you have a guest running in VirtualBox – the host system crashes, or something else happens, and then when you boot up, you find that you can no longer open that VM. You click on the icon in the VirtualBox panel and a message pops up indicating that it’s corrupted. I’ve had this happen to me a on a couple of occasions, and I’m sure there are other VirtualBox users out there who have experienced this too. If you haven’t, then read along anyway, because you might need a fix like what I’m about to give you at some point in the future. This isn’t so much a method of fixing the broken VM, rather it is a method of salvaging the files that were on it, and moving them to a new VM that you can actually use. This method is not particularly clever or elegant, but hey, it works.
This happened last summer to my first MS-DOS 6.22 VM. I had to reboot my host due to a problem – or maybe I was reverting to a restore point – I don’t remember the exact details. Anyway, when I logged back in, the VM no longer worked. When I clicked on the icon in VirtualBox, it said it was corrupted. I still had files on that VM that I wanted to get out of there – nothing that important (I don’t typically use my VirtualBox VMs for anything of a mission-critical nature) – but just random text files that had information I still wanted to use. So I came up with a quick-and-dirty fix, and fortunately I took screenshots as I was doing it, so I can now post them here.
Here’s a screenshot of the error message I got. If anyone knows what that means, please let me know in the comments. I’m no VirtualBox expert and mostly learned how to use the program by just playing around with random controls, so decoding these error messages is way above my head.
What you want to do now is create a new VM. Click on the “New” button on the left-hand side of the top panel. Select the same specs as you had for the old VM, until you get to this window:
Instead of the default option, you want to select “Use an existing virtual hard disk file”. Go to the drop-down menu below as shown in the screenshot and select the hard disk image you were using for your old VM. Chances are your files are perfectly fine; it’s the machine itself that’s fucked. You are in essence creating a carbon copy of your old guest system, except that the hard drive is technically shared between the old one and the new one.
Go through the rest of the dialogues and continue selecting the same specs as your old system. Tell it to create the VM. You now have a working rescue VM installed in VirtualBox. Click on Start and let it boot.
Here we see my rescue VM booting and running the same AUTOEXEC.BAT file that I had on the old VM. You can now access all your files again. I suppose making a copy of the disk image and using that would also work, and that way you wouldn’t have to share a hard drive with the corrupted system. It wouldn’t show up in the drop-down menu so you’d have to click on the folder icon to select a file from the filesystem. I didn’t actually consider this at the time; it literally just occurred to me as I was writing this. Anyway, that’s all for today, folks. Happy hacking.