Like it!

Join us on Facebook!

Like it!

How to resize a VirtualBox disk

My VirtualBox guest OSes always run out of space.

My daily task is to resize a VirtualBox disk, because I ran out of space in it. The operation takes place in two stages: resize the disk itself and then enlarge the primary partition.

1. Increase the disk size

I'm going to use VBoxManage, a tool for managing VirtualBox via the command line. Open a terminal window and use it as follows:

VBoxManage modifyhd </path/to/your/disk.vdi> --resize <new size in MB>

For example:

VBoxManage modifyhd "/home/me/VirtualBox\ VMs/windows\ 7\ 64bit/windows\ 7\ 64bit.vdi" --resize 102400

Note: the path to the .vdi file must be absolute. If it contains spaces, wrap it up in quotes (as I did).

For the gigabytes to megabytes conversion, I found a nice utility here.

2. Extend the partition to use the new space

Your disk is larger now, but not yet used by the operating system. It is time to use a partition manager to enlarge the primary partition in order to take advantage of the new space available.

You can rely upon GParted for this kind of task. It works fine on Linux, Windows and Mac OS X partitions. On Windows Vista and newer you can also use the Disk Management tool shipped with the operating system utilities.

Sources

VirtualBox forum - How to resize a Virtual Drive (link)
VirtualBox site - Chapter 8. VBoxManage (link)

comments
Richmond on February 24, 2018 at 18:57
This was helpful, thanks. Newer VirtualBox versions add the "modifymedium" command. It's just a more modern version of it. More information: https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi
TrasherDK on March 15, 2020 at 16:43
Being able to decrease a disk would be useful.

Adding space on a Linux guest is as easy as mounting a disk to the area where space is needed.