You need to convert an existing physical machine running Windows or Linux to its virtual machine equivalent. This article provides instructions on how to carry out a physical to virtual (P2V) conversion.
If you are running a Windows 7 or Windows 10 physical machine, you should download the Disk2VHD application from Windows Sysinternals. After extracting the contents of the downloaded .zip file the following executables are available. Run the “disk2vhd64.exe” on Windows 64-bit systems.
The Disk2VHD user interface lists the available system partitions and offers the following configuration options.
Option for MBR partition, does not need the extra bootable partition for the final vhd(x) to be bootable.
Option for GPT partition, needs also the bootable partition for the final vhd(x) to be bootable.
Disk2VHD has an option for .vhdx for HyperV or .vhd for compatibility with other hypervisors.
There is a also a CLI-based equivalent of the GUI. Details about running CLI commands in Disk2VHD can be found at https://docs.microsoft.com/en-us/sysinternals/downloads/disk2vhd.
In a separate KB article, i have provided instructions on how to use Linux dd to clone a memory card to another memory card: https://stefanos.cloud/kb/how-to-clone-a-memory-card-in-linux/. In a similar fashion, you can first boot your Linux computer with a Linux Live CD, such as Ubuntu Live, Kali Linux, System Rescue CD or any other live CD of your preference. Then you can run the dd command with the necessary parameters to clone a physical machine into a virtual disk (file image), as shown in the example command below.
dd if=/dev/hdc bs=4k conv=noerror,sync | ssh -c blowfish [email protected] 'dd of=filename.dd' #The below commands transform the created image file above to vhd format by using VirtualBox and VirtualBox Extensions on Linux sudo apt-get update sudo apt-get install virtualbox VBoxManage convertfromraw filename.dd filename.vhd --format VHD
An alternative method would be to make use of the ntfsclone2vhd (https://github.com/yirkha/ntfsclone2vhd) tool in Linux by running the following example bash command.
ntfsclone --save-image -o - /dev/sdc | ntfsclone2vhd - /mnt/usb/myfile.vhd
In case you are a Mac OSX user, you should follow instructions in the below article for P2V conversion of your physical Mac to a virtual machine.
Virtual to virtual (V2V) conversion
After you have completed the Physical to Virtual (P2V) conversion process, you may need to further convert the P2V output file to another file format (.vhd), so that it can be supported by a hypervisor other than Hyper-V or Virtual PC.
You can further make use of the free Starwind V2V converter, to convert the .vhd file to a vmware hypervisor file format: StarWind V2V Converter / P2V Migrator is a free software for cloning and transforming VMs from one format to another, as well as converting physical machines into virtual ones. It is utilized when migration or Hypervisor Switch is required. Compared to the typical converters built into hypervisors, StarWind V2V Converter / P2V Migrator offers bi-directional conversion between all the major VM formats: VMDK, VHD/VHDX (Windows Repair Mode aware), QCOW2, and StarWind native IMG. Further guidance on Virtual to Virtual (V2S) conversion can be found at: https://www.nakivo.com/blog/how-to-convert-vhd-to-vmdk-a-step-by-step-guide/.