Earlier we published a guide about VirtualBox P2V in Windows 10/11 by VMware converter. In this guide, we will learn more about how to do a VirtualBox P2V with a Microsoft utility called disk2vhd. disk2vhd is an excellent virtual hard disk tool to clone the physical disk partitions of a computer (Physical or virtual). It can output the virtual hard disk in VHD format. This VHD file can be converted to other several virtual disk formats or attached to virtualization software like Hyper-V and VirtualBox.
Even though I successfully converted a physical machine to a virtual one by using the disk2vhd tool, it gave me a few errors when I tried to boot the virtual machine from Oracle VirtualBox. Later, found a few solutions to make it work.
Let us discuss the possible errors and how to solve them with Microsofts’s disk2vhd. disk2vhd tool does work on Microsoft Windows Operating Systems only. Also, the tool should be installed locally on the computer to convert it. We can’t use it remotely to convert a network-connected computer/server.
Migrating a working physical Windows computer to the VirtualBox platform is very easy in this way. Once it has been converted to VHD format, we can use it with VirtualBox which can run on any OS like Linux or macOS. 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). I will be converting and moving only Windows 7 to VirtualBox by P2V here.
VirtualBox P2V with disk2vhd and Fix Errors.
1) Download the latest version of disk2vhd (2.02 version)
2) Installation is not required, execute the program directly.
3) It will pick up the physical disk partitions from the host OS.
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.
- If you want to P2V only specific Operating Systems and partitions from a physical computer, then you must do it properly to avoid problems.
In this example, I planned to convert my working Windows 7 to VirtualBox. So, I must convert the System and boot partitions which are usually different in most cases.
Here is my working Windows 7 physical computer.
Initially, I converted only Windows 7 boot partition (normally the C drive) to save space and time. I know this is not the system partition with the boot recorder, but I thought I can repair it and make it work 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 all partitions. When the boot loader/recorder is not found on any of the partitions, 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 the Windows installation medium, but all failed for me. Hence, I need to rerun the disk2vhd P2V conversion.
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 be able to use with Virtualbox or any other platform.
In my above example, the System partition is E and the Boot partition is C. So, I have to select both partitions to convert.
5) Now press Create button and start the process. Make sure that each partition is having enough disk space to create snapshots on the physical 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 the partition structure is converted properly.
Here is another problem I encountered. The converted Windows 7 machine kept on restarting in VirtualBox. Do you know why? My physical hard disk is connected via the SATA port on the host computer. So I attached the VHD file to the SATA port on VirtualBox too, but that was wrong.
It started working after I removed the disk and re-attached it to the IDE port of the virtual machine.
Update: This demonstration was done many years ago with the older VirtualBox and Windows OS versions. By the time you read this guide, VirtualBox and Windows OS would have improved the features and auto fix the errors we faced so far.
Try the Following Steps to Solve disk2vhd Errors with VirtualBox
In summary, here are some of the solutions you can try if the virtual machine is not booting after doing P2V with disk2vhd.
- Make sure that you are converting system and boot partitions
- Remove and attach the converted VHD disk to IDE (if not, SATA) port of the virtual machine
- Change the storage type in virtual machine settings
- Enable or disable IO APIC and PAE/NX
- Insert the Windows installation medium and repair the boot loader and any start-up issues.
Changing disk to IDE from SATA did the trick and I managed to boot on VirtualBox. Here is the successful P2V with disk2vhd.
After the migration, install the latest guest additions to get more features and performance boost.
This will be an ideal way to move your working physical computer to VirtualBox or Hyper-V on a different host computer to get maximum portability.
Even though we demonstrated these steps in older versions of products, still, it will work on Windows 10, Windows 11 and the latest versions of Oracle VirtualBox.