- VBoxManage allows you to easily convert VDI, VHD, VMDK and RAW disks from the terminal.
- Changing the UUID is essential to avoid conflicts when duplicating virtual disks.
- Tools like qemu-img, PowerShell o VMware Converter expands conversion options.
- It is vital to check host system compatibility after format migration.
In the world of virtualization, managing virtual hard drives is a key and frequently repeated task. Converting these drives from one format to another is not only useful for cross-platform compatibility, but also for tasks such as migrations, forensic analysis, or simply facilitating testing in different virtualization software. And if there's a powerful and versatile tool for working with virtual drives, it's it. VBoxManage.
You already use Oracle VirtualBoxWhether you're using VMware, Hyper-V, or even more advanced solutions like QEMU/KVM or Proxmox, knowing how to handle conversion between VDI, VHD, VMDK, and RAW formats gives you a huge advantage. In this article, we'll explain How to convert virtual disks between these formats using VBoxManage and other complementary tools in a precise, detailed manner, without leaving anything out.
What is VBoxManage and why is it important?
VBoxManage is the line interface of commands Oracle VM VirtualBox official. It allows you to perform advanced configuration tasks not available from the graphical interface. Its features include:
- Complete management of Virtual machines: creation, modification, deletion, Boot, off, etc.
- Detailed control of virtual hard drives: create, modify, clone, convert and more.
- Interaction with network devices, USB, shared folders, and snapshots.
- Task automation through scripting and remote control of VMs.
One of the lesser known but most useful aspects of VBoxManage is its ability to change the format of virtual disks, something vital when we want Move a machine from VirtualBox to VMware, Hyper-V, or vice versa.
Most common virtual disk formats
Before getting into the subject, it is important to understand the main virtual disk formats that employ the different virtualization solutions:
VDI (Virtual Disk Image)
Is VirtualBox native format, widely used for its flexibility and easy management. It allows storage Fixed or dynamic size, snapshot capability, and good performance. It's ideal for testing environments and general use.
VHD and VHDX
Its Microsoft formats Primarily used by Hyper-V. VHD is the older version and allows for drives up to 2 TB in size, while VHDX supports up to 64 TB and offers greater resilience to failures thanks to support for 4 KB sectors and power failure recovery.
VMDK
Disc format of VMware, compatible with many hypervisors such as VirtualBox and QEMU. It can be monolithic or partitioned, flat or sparse, with support for snapshots and thin storage, and scales up to 62 TB in modern environments.
RAW
Format without encapsulation and routine forensic useIt's simply a byte-for-byte copy of the disk. Ideal for analysis, data recovery, and compatibility with tools like dd or FTK, although not as efficient in virtualized environments due to its lack of metadata.
Converting disks with VBoxManage
VBoxManage allows you to convert disks between different formats using commands clonehd o clonemedium, specifying the target format. The general syntax is:
VBoxManage clonehd origen.vdi destino.vmdk --format vmdk
can also be used clonemedium
, which is the new standard name since recent versions:
VBoxManage clonemedium origen.vdi destino.vmdk --format vmdk
Practical examples:
Convert VDI to VHD
VBoxManage clonehd disco.vdi disco.vhd --format vhd
Convert VHD to VDI
VBoxManage clonehd disco.vhd disco.vdi --format vdi
Convert VDI to VMDK
VBoxManage clonehd disco.vdi disco.vmdk --format vmdk
Convert VMDK to VDI
VBoxManage clonehd disco.vmdk disco.vdi --format vdi
Convert VDI to RAW (forensic format)
VBoxManage clonehd disco.vdi disco.raw --format raw
In all cases, the conversion requires that the virtual disk is not in use and that the machine is off.
Disk UUID: How to change it to avoid conflicts
When manually cloning disks by copying VDI, VHD, or VMDK files, problems often arise due to duplicate UUIDs, a unique identifier managed by VirtualBox. If two identical disks share a UUID, you will not be able to use both on the same system.
To change the UUID of a virtual disk, use:
VBoxManage internalcommands sethduuid disco.vdi
This automatically generates a new UUID, allowing it to be used as new without conflicts.
It is also useful when you want reuse the same disk on multiple machines or distribute it in different environments.
Other tools to convert virtual disks
In addition to VBoxManage, there are several tools that allow you to convert disks between formats, some with additional features.
QEMU-img
qemu-img is the command-line utility included with QEMU/KVM. It allows you to work with disks in the following formats:
- VDI
- VHD/VHDX
- VMDK
- RAW
- QCOW2, QED and more
Example of converting VHD to VMDK:
qemu-img convert disco.vhd -O vmdk disco.vmdk
Or to convert to RAW format:
qemu-img convert disco.vdi -O raw disco.dd
To install qemu-img in Linux Ubuntu:
sudo apt install qemu-utils
VMware vCenter Converter
Official VMware tool for Convert between formats and migrate physical or virtual machines to VMware environments. You can import VHD, VHDX, VMDK and even RAW disks.
BackupChain
This tool allows you to perform hot conversions of (running) virtual machines, very useful for production environments. Supports Hyper-V, VHD/VHDX, VMDK, and direct exports to VMware even with modified boot compatibility.
Using PowerShell on Windows
Using the Microsoft Virtual Machine Converter (MVMC) snap-in, you can convert disks from PowerShell:
ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath archivo.vmdk -VhdType DynamicHardDisk -VhdFormat vhdx -DestinationLiteralPath destino.vhdx
Important Considerations When Converting Disks
- It is advisable to shut down the virtual machine before converting the disk.Except for tools like BackupChain, most require idle disks.
- Choose the target format based on the platform you plan to run the disc on (VMDK for VMware, VHD/X for Hyper-V, etc).
- Avoid UUID conflicts generating new UUIDs after cloning.
- Check that the guest operating system can boot on the new platform. May require different drivers or boot settings.
- Please note that converting between formats may lose metadata., such as snapshots, annotations, or disk chains in more complex environments.
View virtual disk status and information
With VBoxManage you can inspect a virtual disk with:
VBoxManage showhdinfo disco.vdi
This returns information like:
- UUID
- Format
- Original and assigned size
- Physical route
Modify virtual disks for maintenance
Using VBoxManage also allows modify existing disks, using commands like:
VBoxManage modifyhd disco.vdi --resize 20480
O well:
VBoxManage modifyhd disco.vdi --compact
These commands are used to:
- Increase disk size (resize).
- Reduce unused space (compact), after a mass delete.
- Change access mode (read-only, normal, etc.).
Copies and clones of virtual disks
If you need to clone a disk without changing the format:
VBoxManage clonehd disco.vdi disco2.vdi
In this case, it's duplicated while preserving the original format. You can use it as a starting point for another virtual machine or for non-destructive testing.
Export and import complete machines
VirtualBox allows you to export complete machines in OVA/OVF format, ideal for moving them between systems:
VBoxManage export nombre_maquina -o archivo.ova
And to import it:
VBoxManage import archivo.ova
This includes VM configuration, disks, snapshots, and more. It's a good option when you want to move an entire machine and its entire environment.
Mount virtual disks on the host system
If you just need to access the data on a virtual disk without starting a VM, you can mount it directly:
On Linux
Using libguestfs:
sudo apt install libguestfs-tools
sudo mkdir /mnt/vhd
sudo guestmount --add disco.vhd --ro /mnt/vhd -m /dev/sda1
On windows
From Disk Management > Action > Attach VHD
This is useful for recover files or perform forensic analysis without starting the virtual machine.
The world of virtual disk conversion is vast but manageable if you have the right tools and understand each of the formats involved. Using VBoxManage and qemu-img, you can seamlessly switch between VirtualBox, VMware, and Hyper-V, adapting your environments to your needs. The important thing is not only to convert correctly, but also to verify UUIDs, ensure compatibility with the host system, and adapt the disks to each platform. If you follow these best practices and choose the right tool for each case, you will have complete control over your virtual machine disks.
Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.