Tuesday, October 11, 2016

VMWare - CLI: Convert Virtual Disks - Thick to Thin


Here I show you how to convert  Thick Virtual Disk (all space provisioned at creation) to a Thin Virtual Disk (dynamic space allocation up to the provisioned size).

This is a good way to save space because with a Thin Virtual Disk, only occupies the space of the files It holds at the time.

Warning with a Thin Virtual Disk you migth run out of space in the Datastore and the Disk can’t grow up to the provisioned size.

thin-provisioning

!-- Log in via SSH (must activate first) --
# ssh root@192.168.1.45
Password: *******


!-- List DataStore Disks (if needed)--
# ls -lh /vmfs/volumes/


!-- Access the VM Folder --
# cd /vmfs/volumes/DS-VM-DISK/UBUNTU-VM/
# ls -lh

total 16779272
-rw-------    1 root  root   16.0G Oct 10 00:41 UBUNTU-VM-flat.vmdk
-rw-------    1 root  root    8.5K Oct 10 00:41 UBUNTU-VM.nvram
-rw-------    1 root  root     473 Oct  9 22:28 UBUNTU-VM.vmdk
-rw-r--r--    1 root  root       0 Oct  9 22:25 UBUNTU-VM.vmsd
-rwxr-xr-x  1 root  root    2.6K Oct 10 00:41 UBUNTU-VM.vmx
-rw-r--r--    1 root  root  187.4K Oct 10 00:41 vmware.log


!-- Convert the Virtual Disk - Thick to Thin --
# vmkfstools -i UBUNTU-VM.vmdk -d thin UBUNTU-VM_thin.vmdk
Destination disk format: VMFS thin-provisioned
Cloning disk 'UBUNTU-VM.vmdk'...
Clone: 100% done.


!-- Replace the Thick with Thin (Virtual Disks) --
# rm UBUNTU-VM-flat.vmdk
# mv UBUNTU-VM_thin-flat.vmdk UBUNTU-VM-flat.vmdk
# rm UBUNTU-VM_thin.vmdk


!-- All Looks as When We Started --
# ls -lh
total 3246088
-rw-------    1 root  root  16.0G Oct 10 23:59 UBUNTU-VM-flat.vmdk
-rw-------    1 root  root   8.5K Oct 10 23:59 UBUNTU-VM.nvram
-rw-------    1 root  root    471 Oct 10 23:57 UBUNTU-VM.vmdk
-rw-------    1 root  root      0 Oct 10 16:46 UBUNTU-VM.vmsd
-rw-------    1 root  root   2.5K Oct 10 23:59 UBUNTU-VM.vmx

Now you can power the VM :)

To Reverse It Check Out:

No comments: