VirtualBox uses the .vdi file format when you create a virtual machine. This is the proprietary format of Oracle & VirtualBox. Many other formats are also supported, such as .VMDK, .VHD, .QEMU, and others.
The advantage of a .vmdk file is that it can be used with most virtualization tools: VMware Player, VMware ESXi, Microsoft Hyper-V, Oracle VirtualBox, etc.
Note that this is not an officially supported method for resizing a .vmdk — be careful when manipulating your virtual disk file.
Before any operation, make sure to copy the disk file to a safe location to prevent data loss.
Here is an overview of the process:
- Since the .vmdk disk cannot be modified directly, it must first be cloned into a format that can be easily resized: the .vdi format is a good choice here;
- Once cloned, resize the disk to the desired size. Pay attention to the unit: the size must be specified in Megabytes (MB);
- Once resized, clone the .vdi back to .vmdk format so it can be used again in your virtual machine.
Procedure#
On Windows, if VirtualBox is installed in its default location, VBoxManage.exe is located in C:/Program Files/Oracle/VirtualBox.
Open a command prompt (Start / Run / type cmd) and navigate to the VirtualBox directory:
cd "C:/Program Files/Oracle/VirtualBox"A few tips before running the commands:
- The virtual disk name must be in quotes to properly specify the file;
- Use the full path to the virtual disk files when needed;
- These commands should not break the virtual disk, but as a precaution, always back up your virtual disk files beforehand.
Make sure to respect the exact casing and all symbols such as quotes and dashes.
VBoxManage clonemedium "source.vmdk" "cloned.vdi" --format vdi
VBoxManage modifymedium disk "cloned.vdi" --resize 51200
VBoxManage clonemedium "cloned.vdi" "resized.vmdk" --format vmdkNote: The
clonemediumandmodifymediumcommands replace the deprecatedclonehdandmodifyhdcommands since VirtualBox 5.0. The old commands still work as aliases but should no longer be used.
Once the three commands complete, wait a moment for the cloning and resizing to finish. Then attach the new .vmdk file to your virtual machine.
Whether your VM runs Windows or Linux, both operating systems will automatically detect the enlarged disk — no additional steps are required other than verifying the new disk size.
The same procedure applies when running VirtualBox on Linux — just locate VBoxManage on your system.