Shrink Virtual Machine VMDK
We got a request to reduce the allocated size of Thick
provisioned Virtual machines hard disk. Increasing the VMDK size can be
done in GUI but decreasing the size of VMDK is not allowed. In most cases, For
virtual machine hard disk shrink can be performed via v2v. It is the safest
method to reduce the virtual machine VMDK size but there is an another
simple approach which saves lot of efforts rather than performing
v2v. The below approach is tested in Windows 2008 Operating systems but it may
corrupt your data so i would strongly suggest prepare a back out plan
before perform the disk shrink. One more note to perform the disk shrink
is perform a shrink operation from the OS side using shrink
feature in windows 2008 and then follow the below procedure.
1.
Navigate to Virtual Machine path from your ESX SSH session
cd /vmfs/volumes/Datastore_name/VM_Name
2. Edit the VM_Name.vmdk file using Nano
or vi editor
Below is the content of
.vmdk file.
Let us understand what it is and how do we understand disk
size. In the above screenshot, Size of the disk shows 83886080. How it is
calculated. It is nothing but 40 GB.
40 GB = 40*1024*1024*1024/512 = 83886080
The below GUI snap confirms that VM has 40 GB assigned vmdk..
Lets say for 50 GB = 50*1024*1024*1024/512 = 104857600
To shrink the disk , Edit the descriptor file by vi
VM_Name.vmdk ie. vi test.vmdk
Under extent description replace value between RW _ _ _ _ _
VMFS *-flat.vmdk. In my case it was 40GB disk assigned and hence the value was
83886080. I want to reduce the vmdk by 10 GB so after the shrink vmdk size
should be 30GB.
So for 30 GB, use the below mentioned calculation
30(1024*1024*1024)/512 = 62914560 and save the file.
svmotion the vm to forth and back then VM properties now reflect the new size
of the disk 30 GB
No comments:
Post a Comment