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:
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 - vi vmname.vmdk
- 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.
- vmkfstools -i vmname.vmdk vmname-new.vmdk
- Remove the old vmdk files
- rm vmname.vmdk rm vmname-flat.vmdk
- Once removed, again use the vmkfstools to clone vmdk files of the same old name.
- vmkfstools -i vmname-new.vmdk vmname.vmdk
- Using vi client , remove the hard disk from virtual machine and add again.
Comments
Post a Comment