Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Growing a local datastore from the

command line in vSphere ESXi (2002461)


Last Updated: 6/27/2018Categories: How to

Purpose

VMFS Datastores in vSphere ESXi can be increased in size by adding a new extent on a
different storage device (spanning), or by increasing the size of the existing storage device
and then growing the existing datastore extent to fill that available adjacent capacity.

VMFS Datastore extents may be contained within Primary or Logical partitions, following
the MBR/EBR partitioning scheme. VMFS Datastores on the ESX boot device are contained
within a Logical partition, and those on an ESXi boot device are contained within a Primary
partition.

• Datastore extents within a Primary partition and on a non-Local storage device can
be grown into adjacent space using the vSphere Client or API. For more information,
see the Changing VMFS Datastore Properties section of the ESX/ESXi Server
Configuration Guide for your version of vSphere.

• Datastore extents within Extended and Logical partitions on a Local or Boot storage
device cannot be grown into adjacent space using the vSphere Client. This is the
default layout for an ESX 4.x installation. For more information, see Growing a local
datastore from the command line in vSphere ESX 4.x (1009125).

• Datastore extents within Primary partitions on a Local or Boot storage device cannot
be grown into adjacent space using the vSphere Client. This is the default layout for
an ESXi 4.x and 5.x installation. This article provides steps for growing an existing
VMFS Datastore in a Primary partition to fill available adjacent space on the local
boot device.

Prerequisites:

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. A Datastore on a LUN detected as a snapshot cannot be grown. 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.

Resolution

To increase the size of a Datastore on a local boot storage device, recreate the partition layout
to accommodate the larger filesystem, and then grow the Datastore to fill the larger partition.

1. Use the boot device hardware's management tools to add additional disk capacity to
the device. For more information, engage your hardware vendor.

2. Open a console to the ESXi host. For more information, see Using Tech Support
Mode in ESXi 4.1, ESXi 5.x, and ESXi 6.0 (1017910).

3. Obtain the device identifier for the Datastore to be modified (eg: naa, mpx, eui, vml,
etc). For more information, see Identifying disks when working with VMware
ESXi/ESX (1014953).

# vmkfstools -P "/vmfs/volumes/DatastoreName"

Example output:

VMFS-3.33 file system spanning 1 partitions.


File system label (if any): DatastoreName
Mode: public
Capacity 145223581696 (138496 file blocks * 1048576), 43937431552
(41902 blocks) avail
UUID: 4a14d968-88bf7161-700f-00145ef48f76
Partitions spanned (on "lvm"):
mpx.vmhba0:C0:T0:L0:3

The following 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.

4. Record the amount of free disk space on the Datastore. For more information, see
Investigating disk space on an ESX or ESXi host (1003564).

5. 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 get "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0"

For example, a disk containing an ESX 4.x installation with 8 existing partitions:

15360 64 32 40000001 - Geometry of the disk. Disk size in sectors


is 40000001.
4 32 8191 4 128 - Primary #4, Type 4=Fat16<32MB, Bootable, Sectors
32-8191<BR>1 8192 1843199 5 0 - Primary #1, Type 5=Extended,
Sectors 8192-1843199
5 8223 520191 6 0 - Logical #5, Type 6=Fat16, Sectors 8223-520191
6 520224 1032191 6 0 - Logical #6, Type 6=Fat16, Sectors 520224-
1032191
7 1032224 1257471 252 0 - Logical #7, Type 252=0xFC=VMKcore,
Sectors 1032224-1257471
8 1257504 1843119 6 0 - Logical #8, Type 6=Fat16, Sectors 1257504-
1843119
2 1843200 10229759 6 0 - Primary #2, Type 6=Fat16, Sectors 1843200-
10229759
3 10229760 31457279 251 0 - Primary #3, Type 251=0xFB=VMFS, Sectors
10229760-31457279
| | | | |
| | | | \--- attribute
| | | \------- type
| | \---------------- ending sector
| \------------------------- starting sector
\--------------------------- partition number

6. Identify the partitions which need to be resized, and the size of the space to be used.
From the example in step 5, Primary Partition 3 is the last partition on the disk, and
there is empty free space between this partition and the end of the disk. For example:

103 103 125 125 184


82 520 520
219 222 747 750 311
23 191 224
1 4 1 4 9
Logic Logical
al #5 Logical #7 Logical
Type #6 Type #8 Datastor
6 Type 6 252 Type 6 e
(Fat1 (Fat16) (VMKcor (Fat16)
6) e)
224 184
6 1022 1022 3145 3145 4000
909 2474010 520191 320
3 9759 9760 7279 7280 0000
9 0
Prima
ry
Parti Primary Primary Empty
tion Partition 1 #2 #3 Space
Type Type 5 (Extended) Type 6 Type 251 To Be
4 (Fat16) (VMFS) Used
(Boot
able)

7. Identify the desired ending sector number for the target VMFS Datastore's partitions.
To use all space out to the end of the disk, subtract 1 from the disk size in sectors as
reported in step 5 to obtain the last usable sector or use partedUtil
getUsableSectors to get the last usable sector.
8. For example, disk sector count 40000001 - 1 = 40000000 as the last usable
sector, matching the output of the command:

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

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

# partedUtil resize "/vmfs/devices/disks/Device" PartitionNumber


NewStartingSector NewEndingSector

For example, to resize the Primary partition 3 from the example in step 5:

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


10229760 40000000

10. The GPT partitioning scheme places a backup copy of the GPT header at the end of
the disk device. Some operating systems detect the validity of GPT by looking for
this backup copy. Since the disk size was increased, the end of the disk is comprised
of blank space with no backup present. Recreate the backup GPT header using the
partedUtil fixGPT command, specifying the device:

# partedUtil fixGpt "/vmfs/devices/disks/Device"

11. During step 8, the partedUtil command may have reported a warning:

The kernel was unable to re-read the partition table on /dev/Device


(Device or resource busy).

If you receive this warning, reboot the host before proceeding with the next step.
For more information, see Rebooting an ESX Server host (1003530).

12. The partition tables have been adjusted, but the VMFS Datastore within the
partition is still the same size. There is now empty space within the partition in
which the VMFS Datastore can be grown. For example:

82 520 520 1032 1032 1257 1257 1843


23 191 224 191 224 471 504 119
Logica
Logical Logical Logical Empt
l #5
#6 #7 #8 Datas y
Type 6
Type 6 Type 252 Type 6 tore Spac
(Fat16
(Fat16) (VMKcore) (Fat16) e
)
6 2249 1843 1022 10229 4000
2474010 520191
3 099 200 9759 760 0000
Primar
y Primary
Primary #3
Partit Partition 1 #2
Type 251
ion 4 Type 5 (Extended) Type 6
(VMFS)
(Boota (Fat16)
ble)

13. Run this command vmkfstools -V to perform a refresh of the VMFS volumes.

14. 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"

15. Validate that the size of the VMFS Datastore has increased. For more information,
see Investigating disk space on an ESX or ESXi host (1003564).

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.

You might also like