How to shrink size of a vmdk file in ESXi 5.0?
When we try to reduce or shrink the size of an
existing vmdk file, the operation fails.
Resolution
There is no option to reduce the size using
vSphere client. For this you may need to use putty or cli. Please remember to
delete unwanted data from the OS and to shrink the partition internally using
the diskmgmt.msc tool. After shrinking , perform the below:
- Login to the ESXi using putty
- Browse to the vmdk location (eg: cd vmfs/volumes/datastore1/VMname)
- Take a backup of the existing vmname.vmdk and vmname-flat.vmdk files using the cp command in linux (cp filename backup_filename)
- Open the vmdk file using vi editor
- Modify the value corresponding to RW to the required disk space. If you need to shrink the file to xGB, use the value : x*1024*1024*2. For eg: if you want to shrink the disk to 25GB, give the value 25*1024*1024*2= 52428800
- Once finished save the file and use vmkfstools command to clone a disk using the new settings.
- Remove the old vmdk files
- Once removed, again use the vmkfstools to clone vmdk files of the same old name.
- Using vi client , remove the hard disk from virtual machine and add again.
sorry but how can you clone after removal? or didnt i get it?
ReplyDeleteThe clone is taken of the newly created vmdk file
ReplyDeleteThere is a mistake in the following step:
ReplyDeleteRemove the old vmdk files
rm vmname.vmdk rm vmname-new.vmdk
It should be:
Remove the old vmdk files
rm vmname.vmdk rm vmname-flat.vmdk
the steps mentioned in the jpg are fine, though.
Thanks for the correction.
ReplyDelete