If you want to use or migrate VirtualBox virtual machines to Hyper-V on Windows 10 or Windows servers, follow this guide. We can’t discuss the direct export or import migration methods since both products run on different platforms. We have to convert the hard disk of the VM from VirtualBox, then attach to Hyper-V.
As an alternate method, we can use any P2V tools to directly convert the VirtualBox VM to Hyper-V (Considering that VirtualBox VM is running on physical hardware). But, in this guide, we will convert the VDI file to VHD to achieve this task.
Microsoft Hyper-V doesn’t support VDI (VirtualBox hard disk file) file type, therefore it should be converted to VHD (MS Virtual Disk format) or VHDX. Here, I’m going to show how to convert a working Windows VM from VirtualBox to VHD and attach to Hyper-V.
We do not need any third party software for this conversion since the built-in VirtualBox command will do the job well.
Steps to Convert VDI to VHD (VirtualBox to Hyper-V)
Note: It is recommended to uninstall the VirtualBox guest additions from the VM before starting the migration. It may cause an issue on the Hyper-V platform.
VirtualBox snapshots keep separate VDI files for each machine. So if you convert the original base VDI file, you will not get the latest state of the virtual machine. Also, you can’t convert snapshot VDI files separately. Therefore it’s recommended to delete snapshots, that will merge current machine’s state to the single original disk file.
We Can Convert in 2 Ways,
- Using the VirtualBox Media manager
- Using the command line tool.
VDI to VHD by VirtualBox Media Manager
1) Click on File in VirtualBox and open Virtual Media Manager.
Obviously, the VM should be powered off before proceeding further.
2) Select the appropriate disk that is attached to the VM you want to migrate. Click on Copy.
3) In the next disk copy option, select the VHD file format as output.
4) Next screen gives the option to make the disk dynamic or fixed size. If you are familiar with a Virtualization platform, you must be aware of them. For testing and less disk usage, you can try dynamically allocated disks. For production and high disk utilization usage, always use the fixed disk option.
5) Select the path of the VHD file and start copying. It will start copying/cloning the selected VDI file to VHD disk format.
Now you have the VHD file which converted from VDI by using GUI screens.
Convert VDI to VHD in Command Prompt (VirtualBox Tool)
1) Once the prerequisites are met (like uninstalling guest additions, deleting snapshots and powering off the VM), run the following command from the VirtualBox installation location.
vboxmanage clonehd WinXP.vdi F:\winxp.vhd --format VHD
WinXP.vdi – Working VM hard disk
F:\winxp.vhd – Destination and file name of VHD
The above command returned the following error.
2) This is because it is attached to one virtual machine and listed in the virtual media manager. Release and remove the disk from virtual media manager (Note – Do not remove the VDI file from physical hard disk).
Run the command again, it will return following the successful conversion message.
VDI to VHD then VHDX
If you want the latest and recommended file format of Hyper-V which the VHDX, you can convert VHD to VHDX by using Hyper-V disk utility.
The steps are simple and you can refer to this guide.
So basically you need to convert the VDI to VHD by using VirtualBox tools, then the VHD to VHDX by Hyper-V disk tool.
Attach the Disk to Hyper-V VM
Remember, as mentioned earlier this is not the export-import way. We have just converted the disk to VHD which is compatible for Microsoft Hyper-V.
a) Create a new VM in Hyper-V. Setup the hardware configuration as you wish, but instead of creating a new virtual hard disk, you must attach (browse) the converted VHD or VHDX to the VM configuration.
2) Power on the virtual machine. Since the hardware platform (VirtualBox to Hyper-V) is changed for the Operating System, it may install additional drivers and tools for its platform. Restart the VM if required. Make sure to installation Hyper-V guest additions to get better performance and features.
Here is the screenshot of working same virtual machines on both desktop virtualization software.
It hardly took 5 minutes to convert this working machine (2GB VDI) to Virtual PC. Some blogs and forums mentioned about third-party software to convert VDI to VHD, but it can be done easily by VirtualBox command as shown here. I hope this guide is helpful.