Shrink a thin-provisioned VMDK

If you’ve thin-provisioned a VMDK under ESXi and need to reduce it for whatever reason, the official VMware documentation suggest to migrate the VM to another datastore using VMware converter which is not always practical, thankfully an alternative exists.

If you have enabled Change Block Tracking (CBT) be sure to disable it by adjusting the ctkEnabled option on the virtual machine and consolidating disks before you begin.

To reclaim space you need to fill all unallocated space with zeros. On Windows you can use SDelete or the following command on Linux:

cat /dev/zero > zero.dat;sync;sleep 1;sync;rm -f zero.dat

Once the space has been filled with zeros you can shrink the partition as required. I usually use GParted for this. With your partitions shrunk the next step is to reclaim the space, shut-down the VM and SSH into your ESXi host. “CD” to the directory containing the VM and identify the file you need to shrink for example:

# cd /vmfs/volumes/SXi01-local/SRVGEN02
/vmfs/volumes/53930418-064abd7c-45c9-002590dbfde4/SRVGEN02 # ls -lsah
total 119558160
     8 drwxr-xr-x    1 root     root        2.6K Feb 21 11:01 .
  1024 drwxr-xr-t    1 root     root        2.6K Jan 15 13:27 ..
  8192 -rw-------    1 root     root        7.5M Feb 21 11:00 SRVGEN02-000001-ctk.vmdk
  1024 -rw-------    1 root     root      244.0K Feb 21 11:00 SRVGEN02-000001-delta.vmdk
     0 -rw-------    1 root     root         387 Feb 21 11:00 SRVGEN02-000001.vmdk
  8192 -rw-------    1 root     root        7.5M Feb 21 10:59 SRVGEN02-ctk.vmdk
119531520 -rw-------    1 root     root      120.0G Feb 21 10:59 SRVGEN02-flat.vmdk
  1024 -rw-------    1 root     root        8.5K Feb 21 10:59 SRVGEN02.nvram
     0 -rw-------    1 root     root         589 Feb 21 10:59 SRVGEN02.vmdk
     0 -rw-r--r--    1 root     root          77 Feb 21 11:01 SRVGEN02.vmsd
     8 -rwxr-xr-x    1 root     root        3.0K Feb 21 11:00 SRVGEN02.vmx
     0 -rw-r--r--    1 root     root         263 Jan 17 13:55 SRVGEN02.vmxf
  1024 -rw-r--r--    1 root     root      353.9K Feb 21 10:52 vmware-10.log
  1024 -rw-r--r--    1 root     root      182.9K Feb 21 10:59 vmware-11.log
  1024 -rw-r--r--    1 root     root      182.2K Feb 19 18:53 vmware-6.log
  1024 -rw-r--r--    1 root     root      182.3K Feb 19 19:01 vmware-7.log
  1024 -rw-r--r--    1 root     root      182.3K Feb 19 19:10 vmware-8.log
  1024 -rw-r--r--    1 root     root      183.2K Feb 21 10:46 vmware-9.log
  1024 -rw-r--r--    1 root     root      104.2K Feb 21 10:59 vmware.log

Next, run “vmkfstools –punchzero DISK_NAME.vmdk” to actually shrink the file. How long this takes will depend on the underlying storage, on a reasonably fast SSD this took less than ten minutes for me to shrink 110GB:

/vmfs/volumes/53930418-064abd7c-45c9-002590dbfde4/SRVGEN02 # vmkfstools --punchzero SRVGEN02.vmdk
vmfsDisk: 1, rdmDisk: 0, blockSize: 1048576
Hole Punching: 100% done.

Cisco ASAv on ESXi Standalone

Cisco released their new ASAv virtual appliance, an updated virtual offering for the ASA platform. I suspect at least part of the driver for this is their work on Cisco Modeling Labs, a new tool to help build and simulate environments.

The ASAv copes well in terms of performance and allows for yet more physical devices to be virtualized, however it only supports VMware environments that make use of vCenter. This leaves those wishing to use the ASAv for their learning, or testing having to setup vCenter. For home labs this is going to eat up more memory and discourage some. Thankfully working around this if fairly straightforward if you have access to a vCenter environment to import and then export the VM from.
Continue reading Cisco ASAv on ESXi Standalone

VMware Certified Associate (VCA) Exam

Last week I was browsing the VMware website in an attempt to figure out the certification paths available when I noticed some new certifications had launched, VMware associate. The associate certificate sits at the very start of the certification route, and is available as an on-line exam. No need to head to a testing centre.

VMware offer the associate certification in four flavours:

  • Cloud (VCA-Cloud)
  • Data Center Virtualization (VCA-DCV)
  • End User Computing (VCA-WM)
  • Network Virtualization (VCA-NV)

The most relevant for me is the Datacenter certification. After registering on the VMware website I sat through the three hour training course. The first part of the course is a high level overview, before part two which covers the VMware products available and the business problems they help solve.

VMware Certified Associate Data Center

Continue reading VMware Certified Associate (VCA) Exam