After I published a post about VirtualBox P2V, physical to a virtual environment by VMware converter, here I show how to do a VirtualBox P2V with Microsoft utility called disk2vhd. disk2vhd is an excellent disk creation took which can clone the physical disk partitions of a computer (Physical or virtual) and output to virtual hard disk format VHD. This VHD file can be converted to other virtual disk formats or attached to virtualization software.
Even though I successfully used disk2vhd to convert a physical machine to virtual, it gave a few errors when I booted the virtual machine from Oracle VirtualBox. But, I managed to solve it and boot the virtual machine successfully. Let’s see how to solve these possible errors and do VirtualBox P2V with Microsofts’s disk2vhd successfully. disk2vhd will work on Windows Operating Systems only. Also, the tool should be installed locally on the computer to convert it. You can’t use remotely.
Migrating a working physical Windows computer to VirtualBox platform is very easy in this way. Once it has been converted to VHD format, it can be used with VirtualBox that runs on any OS like Linux or Mac OS X. Since VirtualBox supports VHD file format natively, we do not need to convert the VHD to VDI in this case.
In this example, I converted my physical computer that is having two Operating Systems (Windows 7 and Windows XP). But only Windows 7 will be moved to VirtualBox by P2V here.
VirtualBox P2V with disk2vhd and Fix Errors.
1) Download the latest version of disk2vhd (2.01 version)
2) Installation is not required, run the program directly.
3) It will pick up the physical disk partitions from host OS.
Important Note: My mistake
Before going to the next step, let’s understand something clearly!
If you want to convert your entire physical disk (for example 500GB with 5 partitions) to VHD, then select all partitions and start the conversion. This will not cause any issues while attaching the VHD to VirtualBox or Hyper-V.
But, if you want to P2V only specific Operating System and partitions from a physical computer, then you must do it properly to avoid problems later.
In this example, I had to convert my working Windows 7 host to VirtualBox. So, I must convert the System and boot partitions which are mostly different.
Here is my working Windows 7 physical computer.
Initially, I converted only Windows 7 boot partition (normally C drive) to save space and time. I know this is not the system partition with boot recorder, but I had the confidence to repair and boot virtual machine if it fails to boot later.
No matter how many partitions you select and convert, VirtualBox will detect the VHD as the size of a full physical disk with correct partitions. When the boot loader/recorder not found on any of the partitions (Normally it’s on the first partition – E drive for me), OS will not boot.
So, my first method returned the following error
A disk read error occurred
Press Ctrl+Alt+Del to restart
It’s because of the missing system partition. I tried several methods to write the MBR and do the repair with Windows 7 installation CD but all failed for me.
4) So before starting the conversion, go to disk management and check the partition structure.
Always you must convert the system and boot partitions by disk2vhd to able to run on Virtualbox or any other platform.
5) Now press Create button and start the process. Make sure that each partition is having enough space to create snapshots on the computer. It’s highly recommended to do nothing while conversion is happening on the computer.
6) After completed successfully, create a new virtual machine with the correct OS type and attach the converted VHD file.
Once you power on the VM, it should boot and work fine if everything is fine.
But I faced another problem here. The converted Windows 7 machine kept on restarting in VirtualBox. You know why? my physical hard disk connected via SATA port on the host computer, so I thought that it should be attached to SATA port on VirtualBox too, but that was wrong.
It started working after I removed the disk and re-attached to IDE of the virtual machine.
Try the Following Steps to Solve disk2vhd Errors with VirtualBox
In summary, here are some of the solutions if the virtual machine is not booting after converting a physical computer to virtual by using disk2vhd.
1) Make sure that you are converting system and boot partitions
2) Remove and attach the converted VHD disk to IDE (if not, SATA) port of the virtual machine.
3) Change the storage type in virtual machine settings and try
4) Enable or disable IO APIC and PAE/NX
5) Insert Windows installation medium and do a repair such as boot loader fix or start-up issues fixing.
Changing disk to IDE from SATA did the trick and I managed to boot on VirtualBox. Here is the successful P2V with disk2vhd
Install the latest guest additions to get more features and performance boost. It took around one hour to convert 60 GB data (included required two partitions).
This will be an ideal way to move your working physical computer to VirtualBox on a different host computer and give more portability options.
Even though these steps had been demonstrated on Windows 7 host computer with older versions of VirtualBox and Disk2VHD, still, it will work for Windows 8.1, Windows 10 and latest versions of Oracle VirtualBox.