I have been testing out Solarwinds MSP backup, and one of the features this has is that you can restore the backup to a virtual disk, which is in VMware vmdk format.
I have tended to use Oracle VirtualBox locally for my virtual machines since it is compatible with a lot of appliance templates and vhd images you can download online and is free and has a small footprint. Although Windows 10 now does include a cut down version of hyper-v allowing you to run virtual machines, you do need the PRO version of Windows, which I did not have at the time of writing this, I was running Windows home edition.
While the vmdk file does work with VirtualBox natively, I discovered that it does require some work to get it to boot and you cannot do much else with it, which includes shrinking it. This is one thing I needed to do in order to reduce the amount of space used by my restored virtual disk image.
Firstly in order to get the vmdk to boot I had to enable EFI mode in virtualbox settings.
I then had to run bootrec/rebuildbcd
To compact the disk, I discovered I have to convert the vmdk to a VDI file. thankfully this turned out to be quite simple.
If you will not be using a dynamic disk, and do not need to shrink it, then you can skip these first 3 steps obviously.
1. Delete Unnecessary Files from the VM
- The best way to do this is to run the Windows disk cleanup tool, including the option to “clean up system files”
2. Defragment the Disk
- If you want to also shrink the disk, then Using the Windows defrag tool will help with the shrink process.
3. Clean any free disk space
After the disk has been defragmented, the virtual Windows drive will still have unused space containing garbage bits and bytes. These garbage bits and bytes are from the contents of files that used to occupy that space but that are no longer there.
The most effective way to clean free disk space on a Windows drive is to overwrite the unused space with a bitstream of zeros or to zero-fill any free space.
Windows does not come with a native utility to zero-fill unused space but you can find the excellent SDelete tool at Microsoft’s TechNet: https://technet.microsoft.com/en-us/sysinternals/bb897443.aspx
4. Convert the disk
If your vmdk image file is already connected to a guest VM, then you need to remove it, otherwise, the process will not work.
- shutdown the VM
- go into the virtual media manager and remove the vmdk file from the guest VM
Open CMD prompt, and navigate to your VirtualBox folder, from here you will execute VBoxManage, using the coneMEdium command to clone the VHD and convert to VDI.
c:\Program Files\Oracle\VirtualBox> VBoxManage clonemedium disk --format VDI [drive]:[\path_to_file\sourceFile.vmdk] [drive]:[\path-to\destinationFile.vdi]
Obviously, replace the [drive]:[\path_to_file\myserver.vmdk] with your source and destination paths.
This conversion process will actually shrink down the VHD by default if you are using a dynamic disk, and should get it down the minimum required. If it hasn’t sufficiently reduced it, then you can try to run this command.
VBoxManage modifyhd --compact "[drive]:\[path_to_image_file]\[name_of_image_file].vdi"
thanks for your explanations.
The site is very small, tried to zoom in, but zooming does not work on this page for whatever reason
sorry not sure what you mean about the site being small?
it is responsive, so works on any screen size and resolution.
The default width is 1280px.
I’m confused with this part of your instructions:
4. Convert the disk
If your vmdk image file is already connected to a guest VM, then you need to remove it, otherwise, the process will not work.
How does one remove a connection to a guest VM, if the existing vmdk file was created and last used by VMWorkStation? I am wanting to use it as a .vdi file in VirtualBox as a guest VM.
shutdown the VM
go into the virtual media manager and remove the vmdk file from the guest VM
Is this something I need to do in VMWorkStation, or in VirtualBox?
Thank you.
Hello,
“While the vmdk file does work with VirtualBox natively, I discovered that it does require some work to get it to boot…”
That’s an understatement! I’ve been struggling to get a working .vdmi file from VMWorkStation to boot up in VirtualBox. I get what looks like a frozen screen (all black). So, I found your article to try to convert my .vdmi file to a .vdi file.
I’m not understanding Step 4. When you say “go into the virtual media manager and remove the vmdk file from the guest VM”, is that an instruction specific to VirtualBox?
I’m trying to convert a guest machine in VMWorkstation, which is a .vmdk file, to a guest machine in VirtualBox using the .vdi format.
Thank You
this was written 5 years ago and I have no had to do it again since, so I do not remember the specifics.
But I would assume this means to unlink/remove the virtual disk from the VM, as you cannot make changes to them when they are connected.