Storage space is costly and if you do not plan and manage properly you will end up with no space, So in this article, we will cover you how to reclaim free disk space from your VMware vCenter VM’s, since VMware not provide any GUI (like extend disk) to reduce the disk space from vCenter console we can use some command and tricks to reclaim back unused disk from VM’s.
Prerequisites:
- Windows server login credential.
- ESXi host root Login credential.
- VMware vCenter administrator privilege.
Follow below steps for VMware shrink disk :
- Step 1:- Login to Windows system where you have unused space either C: Drive or any Drive go to start and search for Computer Manager and once it opens click Disk Management.
- Step 2:- Once all disk shows under Disk management select the disk which you want to shrink, in my case, I am selecting C: drive OS disk, but you are free to select any disk but make sure you have some free space available.
Click on shrink volume and type the disk size you want to shrink (GB) x 1024 formate and click shrink button.
After shrink disk look like below screenshot.
Shutdown the VM and log in.
Note: For safer side clone the VM and once clone finish follow below steps.
- Step 3:- Login to ESXi host with root user and go to the folder where VM files are the store /vmfs/volumes/datastore name/vm folder/
- step 4:- Select the *.VMDK file and open in vi editors.
- Step 5:- Once the file opens carefully search the heading #Extent description and after RW number is the number which represents your C: disk total size.
Disk size number is calculated by below math formula.
30GB = 30 * 1024 * 1024 * 1024 / 512 = 62914560
As we want to shrink the disk from 30GB to 25GB we taking back only 5GB unused disk space use same formula to get a new number.
25GB = 25 * 1024 * 1024 * 1024 / 512 = 52428800
So finally we got a new number which we need to replace from 62914560 to 52428800 and save the file.
Step 6 Do storage VMotion the VM from one datastore to another datastore to readjust the new storage space and if you want you can move it back to the same datastore.
Once VM successfully migrate power ON the VM and go to VM edit setting to check the new disk space, surprise your disk showing new disk size.
Once VM UP and running login the VM and check the disk space it will be new disk space.
The same step is even applicable to a Linux system where first you need to reduce or shrink the disk size then do the same math and reclaim the unused disk back.
Hope you enjoy this article.