Tuesday, October 11, 2016

VMWare - CLI: Convert Virtual Disks - Thin to Thick

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

The Thick Virtual Disk does not save space, but it is safer because the space is already allocated, there are no surprises. 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[6]

!-- 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 - Thin to Thick (Easy Way) --
# vmkfstools -j UBUNTU-VM.vmdk
Inflate: 100% done.

This option converts a thin virtual disk to Eager Zeroed Thick,
you have the same conversion done bellow the "Hard Way"

 

!-- Convert the Virtual Disk - Thick to Thin (Hard Way) --

image

# vmkfstools -i UBUNTU-VM.vmdk -d zeroedthick UBUNTU-VM_thick.vmdk
Destination disk format: VMFS zeroedthick
Cloning disk 'UBUNTU-VM.vmdk'...
Clone: 100% done.

or

# vmkfstools -i UBUNTU-VM.vmdk -d eagerzeroedthick UBUNTU-VM_thick.vmdk
Destination disk format: VMFS eagerzeroedthick
Cloning disk 'UBUNTU-VM.vmdk'...
Clone: 100% done.

!-- Replace the Thin with Thick (Virtual Disks) (Hard Way) --
# rm UBUNTU-VM-flat.vmdk
# mv UBUNTU-VM_thick-flat.vmdk UBUNTU-VM-flat.vmdk
# rm UBUNTU-VM_thick.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:

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: