Migrating physical computer to virtual machine
February 22, 2010 3 Comments
I recently purchased a new computer and I needed to migrate my old machine to a Virtual Machine. The reasons were many;
- I don’t want to install a lot of old crap that I only use for maintenance of really old projects
- I no longer have access have the installation discs of some of the software on the old machine
- I’m not sure what on the old machine I’ll want in the future, I’d like to migrate software as I find that I need it.
- I sometimes work for an old client at home, and sometimes at their offices. With this virtual machine, I can move my development environment around just as I see fit – from my stationary machine to my laptop – or even to a machine at their facilities
My attempts to migrate the physical machine were fraught with problems, I mean days and days of problems! Not the way I like to spend my evenings and weekends. But in the end, I persevered!
I decided to try to use Virtual PC because there’s a tool Disk2vhd at sysinternals.com, that converts a physical disk to a VHD. I considered Virtualbox, but there’s no conversion tool for Virtualbox. I also considered VMWare’s freeware alternatives, but I decided against it for no good reason. In the end, I tried it and failed using it, so I had to move on.
The Disk2vhd tool worked great, up to a point… Trying to create a virtual machine using the disk I created leaves me with this extremely helpful error message (don’t spoil your users with helpful error messages, they get lazy and stupid if you do!);
Cannot attach the virtual hard disk to the virtual machine. Check the values provided and try again.
So there I am, stuck with a vhd file that can’t be loaded into Virtual PC, some googling around gives up the answer (to be fair, this is spelled out in large letters at the Disk2vhd page);
Note: Virtual PC supports a maximum virtual disk size of 127GB. If you create a VHD from a larger disk it will not be accessible from a Virtual PC VM.
Turns out that while Disk2vhd can convert a physical disk of any size to a vhd file, Virtual PC can’t open files that are larger than a specific size. Hyper-V can load the file, but Virtual PC can’t.
Actually, it’s not even the size of the vhd that’s the problem! The actual size of the vhd doesn’t matter, mine was 35GB, it’s the internal size of the vhd that matters – and since I converted a 650GB disk, the internal size was 650GB. Which is way to large for Virtual PC;
What to do? I found some great tools for shrinking the disk, a command line tool that made me jump through hoops I’d long forgotten. But it was all for naught, the vhd couldn’t be shrunk passed 350GB. Turns out there were locked files on the disk, that couldn’t be moved. I followed every trick in the book (disabled hibernation, disabled system restore, disabled page file, etc). That allowed me to shrink the disk a few more GB. But still no cigar.
Next I tried using different kinds of defrag programs that were supposed to be able to re-locate even these locked files, but alas, no go.
Here I’m about at my wits end, I try using VM Ware tools, but that fails for other reasons. One attempt I made allowed me to shrink the disk and use it with Virtual PC, but then the boot block was broken because the cluster size of the disk had changed. See where I am going with this? Sisyphus, come collect your rock, I don’t want it anymore.
Now I’m ready to degauss the entire disk with a powerful EMP (that would probably gauss the disk instead of de-gaussing it?).
But hold on, I thought, VirtualBox can load vhds, but I was assuming that since Virtual PC can’t read large vhds, surely VirtualBox can’t either? Or can it? But the clue was in the fact that apparently Hyper-V can read larger vhds, so maybe Virtual Box can too?
So I download VirtualBox and ta-da, it just works!
Well, it almost works, now I can’t access the damn network cards and since my old machine is an XP machine, that’s a major problem, because since I can’t access the network, I can’t authenticate the OS. And XP feels that since so many major changes have taken place to the OS, it really really needs to re-authenticate with the mothership. Otherwise it will shut down within two days. Leaves me in a bit of a pickle.
If eventually found a solution for this too, by googling for more hours than I like to think about. But now I have my virtual machine, even though it’s a Virtualbox and not a Virtual PC.