ლ(ಠ益ಠლ)

VirtualBox: Resize Windows Guest Filesystem

Investigating a resize failure of a guest Windows virtual disk in a VirtualBox environment.

Warning

Before proceeding with any modifications to a virtual disk, ensure you have healthy backups in place.

Investigation

The following error was encountered during a resize, following a (recommended) clean shutdown of the Windows guest:

1
2
3
4
$ VBoxManage modifymedium /path/to/guest.vdi --resize XXXXX
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize medium operation for this format is not implemented yet!

Per the VirtualBox documentation, the –resize option is only supported for dynamically allocated disk images, and limited to VDI and VHD.

To confirm the format variant of our Windows guest virtual disk, start by listing all available virtual disks:

1
2
3
4
$ VBoxManage list hdds | egrep -i "location"
Location:       /path/to/guest.vdi
Location:       /path/to/centos.vdi
Location:       /path/to/debian.vdi

With the absolute location of the virtual disk, we can return specific information for the image:

1
2
$ VBoxManage showmediuminfo /path/to/guest.vdi | egrep -i "format variant"
Format variant: fixed default

At this point, we have confirmed that the virtual disk in question is using a fixed format, which (per the above VirtualBox documentation) is incompatible with the –resize option.

Solution

Let’s clone the virtual disk:

1
2
3
$ VBoxManage clonemedium /path/to/guest.vdi /path/to/new.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'VDI'.

Note, the cloning operation may take some time depending on the size of the source virtual disk and the configuration of the underlying storage layer where the image physically resides.

No additional options need to be supplied to the clone command (above) as the default format variant is dynamic.

To confirm the format variant of the new VDI:

1
2
$ VBoxManage showmediuminfo /path/to/new.vdi | egrep -i "format variant"
Format variant: dynamic default

Resize the Partition

Now that the format variant of the new VDI is dynamic, we can proceed with a successful resize:

1
2
$ VBoxManage modifymedium /path/to/new.vdi --resize XXXXX
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

That’s it!

You can now attach the new (larger) virtual disk to your VM and proceed with a filesystem resize (from within the guest as the space has merely been allocated) using whatever tool(s) you prefer, for instance, Microsoft’s built-in Disk Management, GParted, etc.

Happy new year!

Comments