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:
Let's say I want to make it 30 GB. To do this, issue the command similar to the command below.
Under Linux:
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.
Correct the path portion to match the actual path in your environment.
Tip: You can see the path to your VDI file in Virtual Media Manager:
The command works quickly. The VDI file will be resized within a second:
Now click "Refresh" in Virtual Media Manager. It will reflect the changes:
That's it.
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
This procedure did not work for me. Can you tell me why?
I will try, if you specify more details.
Show me please the command output.
Hello from the future, 2021!
This is super awesome and helpful.
Thanks!
Just note that after you resize the disk, just like “real life”, you will need to resize your partition in Linux (if your guest is linux) to take advantage of the new space. You can do this very easily with gparted.