Most of the recent Windows Operating Systems with preinstalled packages/applications are available for download officially in VHDX/VHD file format. Even though these VHD files are mainly made for Microsoft’s server virtualization hypervisor: Hyper-V, but still we can use them on Oracle VirtualBox.
By using pre-installed virtual machine disk files, we can save a considerable amount of time. This simple guide shows how to open and use VHDX and VHD files in Oracle VirtualBox on a desktop computer.
VHDX Vs VHD
- VHD: It is an older format of Microsoft Virtual Hard disk. If you have any virtual machine image in VHD disk format, it is simple and straightforward to attach and use on VirtualBox. You do not need to convert it to any other formats.
- VHDX: It is the upgraded version of VHD. It has lots of improved features than the earlier version. Most of the Microsoft preinstalled images are available in this format. By default, VHDX will be opened as read-only in VirtualBox. As you are aware, with a read-only disk we can’t boot and use Operating System. In most cases, the Operating System will not boot from VHDX in VirtualBox.
We Need to Convert VHDX File
If you have a virtual machine in VHDX file format you want to use in VirtualBox, then you need to convert the file.
We will be covering several ways to convert the VHDX file and attach it to VirtualBox.
How to Convert VHDX to VDI?
If your computer has the VirtualBox program installed, use the below method.
a) Open the command prompt as Administrator.
b) Go to the VirtualBox installation location. Mostly it must be here,
c) Execute the following command. Change the correct path of the VHDX file and where you want the output.
VBoxManage.exe clonemedium disk "D:\Windows2019.vhdx" D:\Windows2019.vdi --format vdi
The above command will output the Windows2019.vhdx file to the VDI file format in the D drive. Based on the size of the disk, it will take a few minutes.
Convert VHDX to VHD for VirtualBox
The Oracle VirtualBox supports VHD hard disk format without any issues. So, converting the VHDX file to VHD will help us to mount and use the required VM on VirtualBox.
To do the below steps, you need to have Hyper-V installed on your Windows computer.
Open the Powershell with admin rights, then execute the following command.
Convert-VHD –Path c:\myvms\win2022.vhdx –DestinationPath c:\myvms\win2022.vhd
Mount and Use VHDX on VirtualBox
Let’s assume you converted the VHDX file to VDI or VHD successfully.
You need to create a virtual machine with the proper OS type that you downloaded from Microsoft or other sites. For example, if you downloaded Windows 2016 VHDX, create a new Windows 2016 VM.
Fine-tune the basic configuration of the virtual machine as you like, for example, processor cores, RAM, etc. But instead of creating a new virtual hard disk, you need to open the existing hard disk.
1) After downloading the pre-installed virtual machine VHD/VHDX file from Microsoft, extract it by opening the EXE file.
In this example, I downloaded Windows 2012 pre-installed VHD file which will be used to open in VirtualBox.
2) Create a Windows 2012 server virtual machine in VirtualBox as below. Make sure to select ‘Use an existing… disk’. Click on the browse button and locate the extracted (or converted) VHD/VDI file.
3) Power on the virtual machine. That will be working from the VHD (or the VDI file) you downloaded/converted.
It is one of the best features of VirtualBox which supports multiple virtual hard disk formats like VHD, VMDK, HDD, and their VDI.
Here is the working Windows 2012 Virtual machine on VirtualBox which was downloaded from the Microsoft site as a pre-installed VHD image.
Hope this guide is useful in converting the VHDX file to VDI or VHD, and then using it in VirtualBox to run the pre-installed Windows Operating System. By the way, this method is applicable to Windows, Linux, and macOS hosts as long as you have the latest VirtualBox.