June 19, 2012 - Warren Held

Virtualbox: Resize VDI or VMDK Virtual Disks

I’ve been approaching the end of my virtual disk on my Windows 7 VM that I run inside Ubuntu at work. I decided now would be a good time to expand it before I run out of room. I had originally been running the VM using VMware for Linux, so my virtual disk was in the VMDK format. It is a little bit trickier to expand a VMDK disk because VirtualBox’s command line tools will not expand the VMDK format (yet). Expanding a VDI (VirtualBox’s native virtual disk format) is a lot easier.

Expand A VDI:

Open up a terminal/command line and use this command

vboxmanage modifyhd "/path/to/your/drive/virtualdisk.vdi" --resize 100000

Note that there are two dashes before resize. The 100000 after it will resize the disk to approx. 100gb. If the working directory of your command line is already in the folder that the virtual disk is in you only need to specify the virtual disk name. You will probably need to put it in quotes if there are spaces in the name.

Expand VMDK:

Expanding a VMDK is a little trickier than expanding a VDI, but it is still a fairly straightforward task. First, since vboxmanage cannot expand VMDKs at the time of writing, you will need to clone the VMDK to VDI format. Then you will need to expand the cloned disk:

vboxmanage clonehd "/path/to/vmdk/virtualdisk.vmdk" "/path/to/new/vdi/virtualdisk.vdi" --format vdi
vboxmanage modifyhd "/path/to/new/vdi/virtualdisk.vdi" --resize 100000
Expand File System:

After you have expanded the virtual disk you will need to extend the partition to use the newly acquired space. You can do this in Linux with gparted, and in Windows using Disk Management (go to the start menu -> type diskmgmt.msc -> hit enter). In both gparted and Disk Management you need to right click on the volume you want to expand and select expand volume/resize. Then drag the bar all the way to the right to expand the volume in gparted, and when you go to expand volume in Windows Disk Management it should already have the unused space allocated, you just have to hit ok.

VirtualBox / Virtualization Virtual Disk / VirtualBox /