Saturday 17 November 2012

Moving Physical Windows 7 to Virtual (VirtualBox) environment

Since I mostly operate in Ubuntu, recently I decided to give up my Windows 7 installation entirely by moving it from physical installation to the virtual one. This should work conviniently as I have a legacy Win 7 which came with the laptop I'm using. After all there are few moments when one needs Windows and I don't feel like rebooting too often.
The trick is that the laptop is a dual-boot machine, so things are not as simple as they could be.

So here are the steps I took:
1. install VirtualBox (in ubuntu simpy use Ubuntu Software Center to accomplish this step)
2. Boot into Windows
3. Make a virtual disk out of your installed Windows 7 partition. Use disk2vhd utility (available here). Select all drivers (don't deselect anything). Save the VHD file in some place that will be available from linux (ubuntu)
4. Make yourself a Windows Rescue Disck (will be needed at later stage); It's a standard Windows procedure, so I'll skip it here (--> google)
5. Reboot into linux and login
6. Start VirtualBox (I'm running version ...)
7. Create a new VM (press new, provide a name, select proper OS, i.e. Windows 7 64-bit)
8. Set VM parameters (RAM, CPU, ... to your preferences); in Storage section enable access to CD/DVD (will be needed to utilize Windows Recovery Disk). Make sure you can boot from a CD/DVD
9. Reboot the virtual machine
10. Select CD/DVD as boot option
11. Boot from Recovery Disk, log in when prompted
12. Select command line as utility
13. Execute the following commands:

Bootrec.exe /FixMbr
Bootrec.exe /FixBoot
Bootrec.exe /RebuildBcd

(the intention here is to get rid of grub in the VM, otherwise you'd be getting grub rescue at boot)

14. Reboot Virtual Machine
15. Log on; you can expect some updates and installations comming after loggin
16. Enjoy!

For now everything seems to work; or at least I'm able to start using my local installation of Win 7 in the virtual machine mode ;)
I intend to report issues if they appear.

P.S. So far no need to do anything with Win 7 registration ;)