Chris Hall bio photo

Chris Hall

Principal Technical Consultant

PolarCloudsUK Chris LinkedIn Github
Chris Hall Nutanix Certified Master - Multicloud Infrastructure 6 Chris Hall VMware vExpert 2024 Chris Hall VMware vExpert NSX 2023 Chris Hall Nutanix Certified Professional - Multicloud Infrastructure 6 Chris Hall Nutanix Certified Professional - Unified Storage 6 Chris Hall VMware vExpert 2023 Chris Hall VMware vExpert 2022

NSX Spun up a quick nested ESXi 7.0 VM for some testing and noticed I needed to expand VMFS datatstore to fit my VMs. As is usual, I’d sized my VM on the slightly small side.

Rather than ‘being tight’ with vSphere resources, I like to think of it as being frugal when allocating resources to VMs. The more frugal you are with resources when allocating to VMs, the more VMs you can get into the environment.
More VMs equals more fun!
:smiley:

Anyway, back to the topic in hand.

Simple enough I thought, I’ll increase the nested ESXi’s diskspace and then expand the VMFS datastore into the newly added space. One, two, three, and oh…

Here is a screenshot of the error I encountered:

Failed to Expand Error Close Up

Failed to expand VMFS datastore datatstore1 - Cannot change the host configuration.

Failed to Expand Error

So how did we get to this error? Is there a way to expand the VMFS datastore?

Spoiler Alert: Yes! There is a way to expand the VMFS, and no you don’t need to trash your datastore first!

Overview

Reproducing the Error

Simple. Try to expand a VMFS datastore that was created on the boot disks of an ESXi install using the host web client:

Step 1 - select Increase capacity:

Step 1

Step 2 - select Expand an existing VMFS darastore:

Step 2

Step 3 - select the datastore to expand:

Step 3

Step 4 - move the slider to allocate the free space to the VMFS partition:

Step 4

Step 5 - confirm and click Finish:

Step 5

Oh look an error:

Step 6 - Error

Doh!

[Solved] How to Expand the Datastore

So if we can’t expand a boot drive datastore through the host web client, we are going to have to drop to the command line to achieve the expansion.

:warning: Standard disclaimers apply! Proceed at your own risk. Follows is for information only. YOU CONTROL YOUR DATA! Back it up first perhaps? :warning:

First, we need some information regarding the disks upon which the partitions are located and the partition number of the VMFS datastore to be expanded. Simple enough; browse to the datastore in the web client and find it’s extent details:

VMFS Info

Extent 0: mpx.vmhba0:C0:T0:L0, partition 8 is the information we are interested in.

Next, lets fire up an SSH session or use the DCUI doesn’t matter which.

Lets use the information gained above to get some further info on the partition table:

partedUtil getptbl "/vmfs/devices/disks/DeviceName"

Get Partition Table

Yep, 8 268437504 419430366 AA31E02A400F11DB9590000C2911D1B8 vmfs 0 is the VMFS partition we want to work on.

Next, lets confirm that the partition structure is OK before we make any changes:

partedUtil fixGpt "/vmfs/devices/disks/DeviceName"

Fix Partition Table

Perfect. Next, let’s find the starting sector of our VMFS partition.

As we can see from the above screenshot, the first number after the partition number of our VMFS in the above figure is our starting sector:
8 268437504 419430366 AA31E02A400F11DB9590000C2911D1B8 vmfs 0

Our VMFS partition starts at sector 268437504.

Next, let’s find the end usable sector on the disk:

partedUtil getUsableSectors "/vmfs/devices/disks/DeviceName"

Get Usable Sectors

As we can see from the above screenshot, the second number returned is the last usable sector on the disk: 34 524287966

524287966 is the last usable sector on our disk.

So putting the info gleamed from the previous commands, we easily can construct the partition expand command. Here is the syntax:

partedUtil resize "/vmfs/devices/disks/DeviceName" PartitionNumber NewStartSector NewEndSector

Using the above information, our command will look like this:

partedUtil resize "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0" 8 268437504 524287966

Resize

Nice. Partition expanded. :thumbsup:

Next we need to expand the VMFS file system into the expanded partition. Here is the syntax:

vmkfstools --growfs "/vmfs/devices/disks/DeviceName:PartitionNumber" "/vmfs/devices/disks/DeviceName:PartitionNumber"

Using the above information, our command will look like this:

vmkfstools --growfs "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0:8" "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0:8"

Grow VMFS

After refreshing the web client:

Job Done

BOOM! :boom: Job done! :thumbsup: :sunglasses: :thumbsup:

All in all, not difficult if you know which commands to run and where to glean the information to put into the commands.

For more information on the ESXi partedUtil command line utility, take a look at VMware KB 1036609.

-Chris