Knowledge Base

|
Growing a local datastore from the command line in vSphere ESX 4.x (1009125)
Purpose
VMFS Datastores in vSphere 4.x 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.
Note: For ESXi 4.x or 5.0 hosts refer to Growing a local datastore from the command line in vSphere ESXi 4.x and 5.0 (2002461)
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 on a non-Local storage device can be grown into adjacent space using the vSphere Client. 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 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 installation. For more information, see Growing a local datastore from the command-line in vSphere ESXi 4.x (2002461).
- 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. This article provides steps for growing an existing VMFS Datastore in a Logical partition to fill available adjacent space on the local boot device.
Notes:
- 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.
- A Datastore on a LUN detected as a snapshot cannot be grown. For more information, see vSphere handling of LUNs detected as snapshot (1011387)
- 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.
- Use the boot device hardware's management tools to add additional disk capacity to the device. For more information, engage your hardware vendor.
- Open a console to the ESX host. For more information, see Unable to connect to an ESX host using Secure Shell (SSH) (1003807).
- 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 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:5
Note: To obtain this information for the Datastore containing the Service Console virtual disk (VMDK) on ESX, use the command:vmkfstools -P `esxcfg-init --cos-vmdk`
- Record the amount of free disk space on the Datastore. For more information, see Investigating disk space on an ESX or ESXi host (1003564).
- Equipped with the device identifier, identify the existing partitions on the device using the
partedUtilcommand. For more information, see Using the partedUtil command line utility on ESX and ESXi (1036609).partedUtil get "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0"
For example, a disk containing an ESX 4.x installation with 4 existing partitions:17834 255 63 286515200 - Geometry of the disk. Disk size in sectors is286515200.1 63 2249099 131 128 - Primary #1, Type 131=0x83=Linux, Bootable,Sectors63-2239099
2 2249100 2474009 252 0 - Primary #2, Type 252=0xFC=VMKcore, Sectors2249100-24740093 2474010 286487144 5 0 - Primary #3, Type 5=Extended,Sectors2474010-286487144
5 2474073 286487144 251 0 - Logical #5, Type 251=0xFB=VMFS, Sectors 2474010-286487144
| | | | |
| | | | \--- attribute
| | | \------- type
| | \----------------- ending sector
| \------------------------- starting sector
\--------------------------- partition number
- Identify the partitions which need to be resized, and the size of the space to be used. From the example in step 5, Logical Partition 5 is contained within Extended Partition 3, they are the last partitions on the disk, and there is empty free space between them and the end of the disk. For example:
Datastore2474073286487114Logical Partition 5
Type 251 (VMFS)632249099224010024740092474010286487114286487145286515199Primary
Partition 1Primary
Partition 2Extended Partition 3Type 5Empty Space
To Be Used
- 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.
For example, Disk sector count286515200 - 1 = 286515199as the last usable sector.
- Resize the partition(s) containing the target VMFS Datastore using the
partedUtilcommand, 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 Extended and Logical partitions from the example in step 5:partedUtil resize "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0" 3 247010 286515199partedUtil resize "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0" 5 247073 286515199
- During step 8, the
partedUtilcommand may report the warning:The kernel was unable to re-read the partion 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).
- The partition tables have been adjusted, but the VMFS Datastore within the partitions is still the same size. There is now empty space within the partition in which the VMFS Datastore can be grown. For example:
DatastoreEmpty Space2474073286515199Logical Partition 5Type 251 (VMFS), Now Larger632249099224010024740092474010286515199Primary
Partition 1Primary
Partition 2Extended Partition 3Type 5, Now Larger
- Grow the VMFS Datastore in to the new space using the
vmkfstools --growfscommand, 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:5" "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0:5"
- 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: Click the Refresh button in the vSphere Client to update the Datastore capacity and usage.
See Also
- Rebooting an ESX Server host
- Investigating disk space on an ESX or ESXi host
- Unable to connect to an ESX host using Secure Shell (SSH)
- Identifying disks when working with VMware ESX
- Using the partedUtil command line utility on ESX and ESXi
- Growing a local datastore from the command line in vSphere ESXi 4.x and 5.0
Request a Product Feature
- Updated:
- Categories:
- Languages:
- Product Family:
- Product(s):
- Product Version(s):

