02 June 2011

How to resize VMDK disks in ESX/ESXi

How can you expand or shrink an existing Virtual disk (vmdk) in esxi/esx.
Since I see that a lot of people wonder how to do this, I thought I'd share with you.
Let me begin with saying that if the disk in question is already "Thin Provisioned", then you don't have to do anything else then shut down the VM and edit the hard disk properties to shrink/expand it.




But sometimes you come across a Thick disk , either you didn't notice it while creating, or whatever... But there is still hope to achieve a thin disk.

There are 2 options to do this (that I know of)

SHUT DOWN THE VM BEFORE DOING ANY OF THE TWO OPTIONS!!!

Option 1
Clone the thick disk to a thin and then disconnect the original thick disk, then you just add the newly created thin disk to the machine and specify the required size. (this is the easiest/fastest and best way imo)

1 Log in to the ESX host using the local console or SSH.
2 Change directories to the target vm (normally: /volumes// )
3 Now issue the following :
vmkfstools -i -d thin
4: This will take some time, depending on the size.
5: Now when this is done, open vcenter/the esx host console and edit the vm hardware, disconnect the old disk and add a new disk. Choose the "existing disk" option and select the new thin disk. (also edit the size while you're at it)
6: Boot the vm, if all seems well you can go ahead and delete the OLD vmdk+vmdk-flat.


Option 2
Use vmware converter to do a V2V convert and while doing so specifying the new disk space. So this is also a way to do this, but the machine must also be shut down+it will take longer and is just overall sluggisher imo...

1: Download the vmware converter
2: Follow the steps in the wizard (choose Virtual 2 Virtual)
3: Choose the right disk format to copy (you can choose the whole disk or a percentage) also mark them as THIN
4: perform the V2V convert and then boot and test the vm, if all is well you can just delete the old vm.

1 comment:

Manas4one said...

Have you ever tried Option-1???

Please confirm if it worked for you