Expanding Local Datastore in vSphere ESXi
search cancel

Expanding Local Datastore in vSphere ESXi

book

Article ID: 321398

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article provides information on how to expand a local datastore which also happens to be the boot location of the ESXi host. This is achieved by growing an existing VMFS Datastore in a Primary partition to fill the adjacent available space on the local boot device.

Note: Datastore extents within Primary partitions on a Local or Boot storage device cannot be grown into adjacent space using the GUI and would need to be performed over the command line only. Prior to expanding the local datastore, ensure to verify and validate the following:
  1. This article assumes that the underlying storage volume has already had its capacity increased from the hardware perspective, possibly by adding additional disk to a RAID set. For more information, engage your hardware vendor.
  2. You cannot expand a datastore that is detected as a snapshot. For more information, see vSphere handling of LUNs detected as snapshot LUNs (1011387).
  3. A Datastore's partitions can only be grown into contiguous adjacent space on the disk. Ensure that the partitions in question are at the end of the disk.

    Warning: Be very careful to not overlap the any Primary and Logical partitions. This could result in data loss.


Symptoms:
  • Expanding the local datastore on the ESXi host fails.
  • You receive this error message similar to:

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

    Failed to expand VMFS datastore datastore1


Environment

VMware vSphere ESXi 6.7
VMware vSphere ESXi 8.0.x
VMware vSphere ESXi 6.0
VMware vSphere ESXi 6.5
VMware vSphere ESXi 7.0.x

Resolution

On the ESXi host containing the local datastore you want to expand:
  1. Open an SSH session and log in as root.
  2. Identify the boot location of the ESXi host by running running this command:

    ls -ltrh

    vmware expand datastore command line
     
  3. Ensure that the symbolic link (symlink) is reflecting in a blue color.

    Note: If the symlink is a red color, this indicates connectivity issues to the underlying device and may not be readable or accessible.
     
  4. Obtain the device identifier for the Datastore (For example: naa, mpx, eui, vml etc.) to be modified by running this command:

    vmkfstools -Ph -v10 bootbank

    For more information, see Identifying disks when working with VMware ESXi/ESX (1014953) .

    vmkfstools --growfs
Note: The next steps use mpx.vmhba0:C0:T0:L0 as an example. Replace mpx.vmhba0:C0:T0:L0 with your device identifier that may begin differently. For example, naa or eui.
  1. Record the amount of free disk space on the Datastore. For more information, see Investigating disk space on an ESX or ESXi host (1003564).
     
  2. Equipped with the device identifier, identify the existing partitions on the device using the partedUtil command. For more information, see Using the partedUtil command line utility on ESXi and ESX (1036609).

    partedUtil getptbl "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0"
     
    The output should be like this indicating the 7 existing partitions, with VMFS occupying partition 3.

    local datastore expansion
  3. The highlighted field indicates the specifics for the VMFS partition.

    expand local datastore
     
  4. Identify the desired ending sector for the VMFS datastores partition by executing the partedUtil getUsableSectors command:

    partedUtil getUsableSectors "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0"

    34 16879000

    Resize the partition containing the target VMFS Datastore using the partedUtil resize command, specifying the existing starting sector of the partition and the desired ending sector:

    partedUtil resize "/vmfs/devices/disks/Device" PartitionNumber NewStartingSector NewEndingSector

    Note: The New Ending Sector here would be 1 sector less than output of the total usable sector obtained in the previous step 7.  New Ending sector > 16879000 - 1 = 16878999.

    For example, to resize the Primary partition 3, run this command:

    partedUtil resize "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0" 3 10229760 16878999

    Note: If the partedUtil resize command fails with this error:

    The kernel was unable to re-read the partition table on /dev/Device (Device or resource busy).

    Reboot the ESXi host before proceeding with the next step.
     
  5. Grow the VMFS Datastore in to the new space using the vmkfstools --growfs command, specifying the partition containing the target VMFS Datastore twice.

    vmkfstools --growfs "/vmfs/devices/disks/Device:partition" "/vmfs/devices/disks/Device:partition"

    For example:

    vmkfstools --growfs "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0:3" "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0:3"
     
  6. Execute  to perform a refresh of the VMFS volumes by running this command:

    vmkfstools -V
     
  7. Validate that the size of the VMFS Datastore has increased by running this command:

    df -h

    Note: The size of the VMFS Datastore can be cached by hostd and vCenter Server, or any connected client. Click the Refresh button in the vSphere Client to update the Datastore capacity and usage.