When creating a virtual machine with VirtualBox, it is easy to choose the wrong size for the virtual HDD. Some day, you might face the issue that there is not enough free disk space left in the virtual machine. Here is how you can resize a VirtualBox HDD image (VDI) without data loss or without reinstalling the guest operating system.
VirtualBox ships with a console tool VBoxManage, which can do a lot of tasks not accessible from the user interface. For example, using VBoxManage you can adjust the BIOS date and time for virtual machines. This tool can be used to resize VirtualBox HDD images.
The command line syntax is as follows:
VBoxManage modifyhd path_to_vdi_file.vdi --resize desrired_size_in_megabytes
For example, let's resize the disk drive connected to my Arch Linux virtual machine. Right now, its HDD size has a capacity of 20 GB:
VBoxManage modifyhd '/home/user/Arch VM/Arch VM.vdi' --resize 30720
Under Windows, you need to open a new command prompt window in the folder C:\Program Files\Oracle\VirtualBox. See the following article: All ways to open the command prompt in Windows 10, and the part "Run the command prompt directly from Explorer". The command will be the same:
VBoxManage modifyhd "c:\Virtualbox VMs\Arch VM\Arch VM.vdi" --resize 30720
Note: The size above is expressed in megabytes so 30 x 1024 = 30720.
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!