Expand VMFS datastore from command line

2

I was recently working on an incident wherein the user was unable to expand VMFS datastore.

The LUN size was increased on the SAN side and the ESXi host was detecting the extended value, but the increase button was greyed out.

Hence we were unable to expand VMFS datastore size from the vSphere Client and as well as the vSphere Web Client.

I am just going to show the steps that were performed from the command line of the ESXi host to expand VMFS datastore.

Let us see this with an example. Assume that the Increase button is greyed out below and the actual VMFS datastore size now is 5 GB.

But you would notice that the underlying LUN size is extended by another 5 GB and the new size of the LUN is 10 GB.

Expand VMFS datastore from command line

Log in to the ESXi host using an SSH session using putty client and run the below command to list the datastores that are currently mounted.

esxcfg-scsidevs -m

Expand VMFS datastore from command line

The one that I am interested in is the iSCSI-5 datastore. Let us run the below command to see the current partition information of the LUN.

partedUtil getptbl /vmfs/devices/disks/t10.F405E46494C45425339433166673D2856693B4D2547503E4

Expand VMFS datastore from command line

You would notice that there is already a VMFS partition that is found on the LUN. You could also verify the different partitions type by running the below command.

Expand VMFS datastore from command line

Next, we will have to find out the usable sector information on the device so that we extend it in the next step.

partedUtil getUsableSectors /vmfs/devices/disks/t10.F405E46494C45425339433166673D2856693B4D2547503E4

Expand VMFS datastore from command line

You would notice that the last sector shown is higher than the current one that we saw when we checked the partition information.

In the next step, we will have to resize the partition information to reflect the extended information.

Subtract 1 from the last usable sector and resize the partition information with the below command.

partedUtil resize /vmfs/devices/disks/t10.F405E46494C4542533943316667
3D2856693B4D2547503E4 1 2048 20971485

You can verify the changes by again running the getptbl command.

The next step would be to extend the datastore size using the vmkfstools utility as seen below.

vmkfstools --growfs /vmfs/devices/disks/t10.F405E46494C45425339433166673D2856693B4D2547503E4:1 /vmfs/devices/disks/t10.F405E46494C4542533943
3166673D2856693B4D2547503E4:1

And the fins step would be to refresh the datastore information by running vmkfstools -V

vmkfstools -V

You can see the updated information by running the vmkfstools against the Volume name.

vmkfstools -Ph /vmfs/volumes/iSCSI-5

Expand VMFS datastore from command line

If you are interested to know more about vmkfstools and how to use it with Virtual Disks, below is an article that I wrote a few days back.

How to use vmkfstools with Virtual Disks

Well, we have successfully extended the size of the VMFS datastores from command line using the partedUtil and vmkfstools commands.

I hope this has been informative and thank you for reading!

Share.

About Author

I am Adil Arif, working as a Senior Technical Support Engineer at Rubrik as well as an independent blogger and founder of Enterprise Daddy. In my current role, I am supporting infrastructure related to Windows and VMware datacenters.

2 Comments

  1. Salam Adil,

    Thanks for this wonderful post. This exactly matched my scenario. However I am stuck at below command for the reason that, I do not want to have any outage. Please confirm if the activity is online or I need to bring down the VMs or I need to perform svMotion of all the VMs to another datastore before extending.

    vmkfstools –growfs vmkfstools –growfs /vmfs/devices/disks/t10.F405E46494C45425339433166673D2856693B4D2547503E4:1 /vmfs/devices/disks/t10.F405E46494C4542533943
    3166673D2856693B4D2547503E4:1

    Also kindly provide the screenshot of the cmdlet for the above command as I guess few extra text is embedded into this command.

    Thanks.

  2. Salam Adil,

    Another alternate which I tried and achieved successful results is to login to any one of the ESXi host in the cluster, access the storage select the LUN go to properties and when you click on increase you will now be able to see the additional space. Select it and increase it.

    Thanks.

Leave A Reply