How to Convert a VMware Pre-allocated Virtual Disk to a Growable Virtual Disk

VMware Server supports both growable and pre-allocated virtual disks. In addition, the disks can be specified to be contained in a single file, or divided into multiple 2GB files.

The virtual disk type is defined at the point that the disk is created. Whilst this is generally not a problem, VMware Server does not support the shrinking of pre-allocated virtual disks. Before a pre-allocated disk can be reduced in size, therefore, it is necessary to first convert it to a growable disk. This can be performed using the Virtual Disk Manager tool (vmware-vdiskmanager).

The vmware-vdiskmanager tool

The VMware Disk Management Tool is a command line tool which is installed by default with VMware Server. The executable file is named vmware-vdiskmanager and is located in \Program Files\VMware\VMware Server on Windows hosts, and /usr/bin on Linux systems.

The tool accepts a number of command-line arguments, a full listing of which can be obtained by running vmware-vdiskmanager with no options.

vmware-vdiskmanager

Virtual Disk Types

The type to which a virtual disk is to be converted is specified using the -t flag, together with the target disk type. This is represented by a number as outlined in the following table:

Type Identifier

Description

0

Growable (single .vmdk file)

1 Growable (multiple 2GB files)
2 Pre-allocated (single file)

3

Pre-allocated (multiple 2GB files)

4 Pre-allocated ESX
5 Compressed for streaming

Performing the Virtual Disk Type Conversion

The vmware-vdiskmanager command requires a number of arugments perform a virtual disk type conversion. The syntax for a type conversion is as follows:

vmware-vdiskmanager -r <oldfilename>.vmdk -t <type> <newfilename>.vmdk

where <oldfilename>.vmdk is the name of the virtual disk image file to be converted, <type> is the number from the above table indicating the target virtual disk type, and <newfilename>.vmdk is the name of the new, converted file.

For example, to convert a virtual disk image file called win2008-1_2.vmdk to a growable disk called new.vmdk the following command would need to be executed:

vmware-vdiskmanager -r  win2008-1_2.vmdk -t 0 new.vmdk

  Creating disk 'new.vmdk'
  Convert: 100% done.
Virtual disk conversion successful.

Once the conversion is completed, the virtual machine will need to be configured to use the converted disk, or the new disk renamed to have the name of the original disk.