How to expand VMFS datastore from the command line (CLI) on vSphere 5.x and 6.x?

By | September 3, 2015

Today I needed to expand a datastore on my nested ESXi 5.5 in my lab. Unfortunately when I resized a VMDK for my ESXi host, I was not able to expand the datastore via Web Client - because no additional space was available! How to expand VMFS datastore from the command line (CLI) on vSphere 5.x and 6.x I did not to want to install again vSphere Client (I know that expanding works under it) 5.5 because already 6.0 installed is not compatible with 5.5. I decided to expand disk via CLI on ESXi host.

Expanding VMFS datastore can be divided into two phases:

  1. Recreating the partition layout to accommodate the larger file system.
  2. Growing the Datastore to fill the larger partition.

In general, we need to use two magic tools: vmkfstools and partedUtil 😉

To change partition layout to accommodate the larger file system we need to do the below steps:

    1. Obtain the device identifier for the Datastore to be modified.

      vmkfstools -P /vmfs/volumes/Datastore_name

    2. Use partedUtil to check existing partition on VMFS volume (should be one partition).

      partedUtil get "/vmfs/devices/disks/mpx.vmhbax:Cx:Tx:Lx"

    3. Use partedUtil to get usable sectors and resize parition.

      partedUtil getUsableSectors "/vmfs/devices/disks/mpx.vmhbax:Cx:Tx:Lx"

      partedUtil resize "/vmfs/devices/disks/mpx.vmhbax:Cx:Tx:Lx" PartitionNumber NewStartingSector NewEndingSector

    4. Refresh VMFS volumes using the command:

      vmkfstools -V

    5. Grow the VMFS Datastore in to the new space using the command below:

      vmkfstools --growfs "/vmfs/devices/disks/mpx.vmhbax:Cx:Tx:Lx:partition" "/vmfs/devices/disks/mpx.vmhbax:Cx:Tx:Lx:partition"

      An example is shown on the below figure. As you can see, it is important to use double dash... 😉How to expand VMFS datastore from the command line (CLI) on vSphere 5.x and 6.x

    For more information please follow VMware KB.

Author: Mariusz

Architect (~ 15 years experience based on passion...) with strong background as a System Administrator and Engineer. Focused on Data Center Solutions: Virtualization/Cloud Computing and Storage/Backup Systems. Currently living in Poland.