Tuesday, 3 December 2013

Shirnking vmware virtual disk(vmdk) to reclaim unused space using command line

Virtual machine virtual disk grows very huge over time despite the fact that the guest os is not taking the space shown by the vmware virtual disk files.

This examples shows how to reclaim unused space using command line tools like vmware-mount and vmware-vdiskmanager.

The size of the virtual machine partitions, output of ls from the guest os

The total used space is only 10gb or so

The size of the virtual disk files on the host

To list the partition on a virtual partition use vmware-mount -p

ex: vmware-mount -p /u02/vm/vm_test_for_prod_handson/vm_test_for_prod_handson.vmdk

Partition has to be mounted to prepare it for shrinking, create a folder to mount the virtual machine partition

mkdir /tmp/vm

Mount the virtual disk partition

vmware-mount /u02/vm/vm_test_for_prod_handson/vm_test_for_prod_handson.vmdk 1 /tmp/vm (This will mount the first partition)

Now start preparing partition for shrinking

vmware-vdiskmanager -p /tmp/vm

After preparing is completed  unmount the partition

ex: vmware-vdiskmanager -d /tmp/vm

When all virtual partitions are prepared, unmount  partitions and start shrinking .

ex: vmware-vdiskmanager -k /u02/vm/vm_test_for_prod_handson/vm_test_for_prod_handson.vmdk


Virtual disk file size after shirnking 

No comments:

Post a Comment