How to convert an existing Windows machine to VirtualBox? [duplicate]

I have VirtualBox installed on my Linux machine (Debian). I need to move a physical Windows 7 machine into my VirtualBox.

How to convert a physical Windows OS to VirtualBox?


I disagree with SimonS' answer.

Using Disk2Vhd is of course an excellent idea: it allows one to make copies of online disks, and you can even store the vhd file locally (i.e., on the Windows machine), even though the reference above claims it is fastest to store the vhd image on a different medium.

The part which is not correct is the one about importing (?) the vhd image in VirtualBox. There is no need to do so: the reference quoted is terribly old (how many years since there were two distinct versions of VirtualBox, one free one for pay, as stated in the reference? I forget). In fact, VirtualBox is already fully compatible with Microsoft's vhd format: when you create the Virtual Machine, instead of assigning it a blank disk, choose Use an existing virtual hard disk file, and point it to your vhd disk.

That's it.


create a vhd of your physical Windows Machine with Disk2Vhd, then create your VM and choose your created vhd instead of a blank disk.

command-line usage example of disk2vhd: disk2vhd * c:\vhd\snapshot.vhd now every component of your Windows OS will be saved in the VHD

sorry for such a short undetailed answer, but that's all you need to know ;-)


You can use raw partitions, i.e. your existing Windows partition, with VirtualBox. It is a slightly advanced topic, and VirtualBox manual warns that

Raw hard disk access is for expert users only. Incorrect use or use of an outdated configuration can lead to total loss of data on the physical disk. Most importantly, do not attempt to boot the partition with the currently running host operating system in a guest. This will lead to severe data corruption.

but I successfully used it 5 or 6 years ago and it worked just fine.

You need to know the Linux device name of your HDD and the number of partition on which you have Windows installed. Then you run the following command:

sudo VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sda -partitions 1,5

where /dev/sda is your HDD and 1,5 are your partitions numbers. For example, if Linux sees your Windows HDD as /dev/sdb2, your device name is /dev/sdb and your partition number is 2. This command will create a VMDK disk at the path specified, and when you use it in your VM, the VM will write directly to your Windows HDD.

The main advantage of this method is that it doesn't take any additional disk space and allows you to use your existing Windows installation in place. But, again, be warned that this will irrevocably modify your existing Windows data and won't allow you to use snapshots for your VM, so if you have really important data, be sure to have a backup before trying this method.