Use Docker and libguestfs-tools to Shrink Virtual Machine Disks (VMDKs)

The following article describes the process for using libguestfs-tools to shrink an existing pre-allocated secondary VMDK, used by a VMWare Ubuntu guest OS.

The process will be performed from the host machine using a customised docker image. The image’s Dockerfile includes libguestfs-tools as part of the build.

The Virtual Machine needs to be offline/shutdown before proceeding. It goes without saying, make backups of any VMDKs before attempting to manipulate them.