Oracle’s VirtualBox software is an amazing product provided for free, that can fulfill most people’s desktop virtualisation needs. Although I work with VMware vSphere and ESXi products all the time, I still use VirtualBox almost daily to prototype or test things out.
When creating new Virtual Machines in VirtualBox a tend to create my disks as a “standard” type. In the VMware universe we call this “thin-provisioning”. The idea is that the guest operating system “thinks” you have a disk of a particular size to work with, however the actual virtual disk file size only grows as it is needed.
Recently though, I later on has a need to upload the virtual disk file to Microsoft Azure which requires that the disk be configured as a “fixed” type.
Unfortunately, you can’t just seamlessly convert between the types. There is a solution however, as Oracle does include a tool with VirtualBox that can create a new virtual disk file and copy the contents of the disk into it.
First off, shut your Virtual Machine down. View the Settings for your virtual Machine and select the virtual disk. The Location of the file will be shown on the right side. Browse to the file location in explorer.
Open another explorer window and browse to the location of your VirtualBox installation. On my Windows 10 desktop the location is C:\Program Files\Oracle\VirtualBox – also leave this explorer windows open.
Enter the following command, substituting in the proper paths.
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe clonehd <path-to-source-disk> <path-to-destination-disk> –variant Fixed
TIP: Save some typing! With both Explorer windows and a command prompt open, I find it easy to drag the VBoxManage.exe file into the command window which automatically places the full file path into the prompt. I also use the same trick for the source and destination disk files which saves a little typing (obviously the destination file won’t yet exist, but you can drag the source file into the window and change the file name).
The progress is shown in the command window. I’ve noticed that it stays at 0% for a long time, seemingly until the new disk file has been created and fully allocated, and then progresses quicker once data begins copying.
I have performed a conversion from the native .VDI disk format of VirtualBox, as well as .VHD file types with the same good results. I imagine a .VMDK file type would work equally as well.
Once the new disk file is created, you’ll need to go back into your virtual machine settings and remove the original disk. Then add a new disk and choose the option to browse to an existing virtual disk file. If you’re positive it starts and works fine you can delete the old disk file.