Home > Linux > Shrink Thick Linux virtual disk (vmdk) in ESX

Shrink Thick Linux virtual disk (vmdk) in ESX

I have thick provisioned server, and I need move it and shrink it. As Thick option provides flat file of full size , even if OS is few GB, I have full size vmdk file ;( which is harder to copy around.  Thin provisioned vmdk disk is possible shrink via ESX shell command ( vmkfstools –punchzero *.vmdk) but what to do if disk is in Thick state ? Its possible, but little bit more complicated.

Excellent post to explain in depth dafuq – http://blogs.vmware.com/vsphere/2012/03/thin-provisioning-whats-the-scoop.html

First of all , check out your disk layout in Linux box. Issuing command like df -h make you aware 😉


linux df command

so I have lot of free space and before shrinking I need fill it by zero to be able shrink unused space. Remember, when you create file, and delete it, its still on filesystem. So, empty space is empty for Operating System but not physically empty.

Simple command like this

dd if=/dev/zero of=ZEROFILE bs=1000000 ; rm -f ZEROFILE

will create empty dummy file with zeros, until your free space is filled up, then it will delete it. It is important to use it on all partitions separately, so you must switch between them.

Output should look like this , similar 😉

dd command

all done, shutdown virtual machine. next step is coming. lets login to ESX shell 😉

Note: on screenshot is missing first fill in / , sorry Im not going to do it again, its slow server. 😉


Categories: Linux Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

%d bloggers like this: