VMware shrink disk is very necessary when you want to reuse your unused disk space. As a limited storage resource, how to reclaim the unused disk which is free in most of the VM’s, it is very easy to expend disk size whenever the given disk is used but how about the situation where you have free space available in one VM and want to take back and reuse in another VM, If you are a VMware admin you must be facing this situation to reclaim or shrink disk size.
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.
- 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.
- 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.