Manually creating a VMFS volume using vmkfstools -C
search cancel

Manually creating a VMFS volume using vmkfstools -C

book

Article ID: 309687

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article provides steps to create a new VMFS volume on a disk which has free, unallocated space.

Note: VMFS Datastores are normally created using the vSphere Client, and it is not necessary to format the disk from the command line. For more information, see the Create VMFS Datastores section.

This method is specific to the local console in ESX/ESXi. For other manual methods, see Managing vSphere Storage using the Command Line Interface (CLI) (1029301).

Environment

VMware ESXi 4.0.x Installable
VMware ESXi 4.1.x Installable
VMware ESX 4.1.x
VMware ESXi 3.5.x Embedded
VMware ESX Server 3.5.x
VMware ESX Server 1.x
VMware ESXi 4.0.x Embedded
VMware ESX Server 2.0.x
VMware ESXi 4.1.x Embedded
VMware ESX Server 3.0.x
VMware vSphere ESXi 5.0
VMware ESX 4.0.x
VMware ESXi 3.5.x Installable
VMware ESX Server 1.5.x
VMware vSphere ESXi 6.0
VMware vSphere ESXi 7.0

Resolution

To create a new VMFS volume from the ESX/ESXi host command line:
 

  • Rescan the storage subsystem to ensure that the host is updated with the latest storage information. For more information, see Performing a rescan of the storage on an ESX/ESXi host (1003988).
     
  • Open a console to the ESX or ESXi host. For more information, see Connecting to an ESX host using Secure Shell (SSH) (308580).
     
  • Select a LUN or storage device you wish to format by its /vmfs/devices/disks/... identifier, starting with vml, naa, mpx, or vmhba. For more information, see Identifying disks when working with VMware ESX (1014953).
     
  • Use the partedUtil for ESXi 5.x/6.x or fdisk for ESXi 3.x/4.x command to print any existing partitions defined on the chosen disk device. For more information, see Using the partedUtil command line utility on ESX and ESXi (1036609) and Partitioning with fdisk.

    Caution: Take care when repartitioning a disk containing data.
    • For ESXi 5.x/6.x, use the partedUtil command to create a new partition with type 251 = 0xFB and a starting offset of 128 on the chosen disk device, overwriting or augmenting any existing partitions. For example, to create a partition number 1, starting at sector 128 and ending at sector 500000, with type 251 = 0xFB:
      • ​​​​​​​​​partedUtil set "/vmfs/devices/disks/DeviceName" "1 128 500000 251 0"
    • For ESXi/ESX 4.0 and earlier , use "partedUtil set" or fdisk

      partedUtil set "/vmfs/devices/disks/DeviceName" ["partNum startSector endSector type/guid attribute"]*
  • For ESXi/ESX 4.1 and later , use "partedUtil setptbl"

    partedUtil setptbl "/vmfs/devices/disks/DeviceName" DiskLabel ["partNum startSector endSector type/guid attribute"]*
     
  • For ESXi 3.x/4.x, use the fdisk command to create a new partition with a starting offset of 128 and type fb. For example: 
Run the command: fdisk /vmfs/devices/disks/naa.60901234567890123456789012345678
  1. Type p and press Enter to list partition information.
  2. Type d and press Enter to delete existing partition information.
  3. Type n and press Enter for new partition.
  4. Type p and press Enter for a primary partition.
  5. Type 1 and press Enter.
  6. For the First cylinder prompt, press Enter for the default.
  7. For last cylinder or +size, press Enter for the default.
  8. Type t and press Enter to change volume type.
  9. Type 1 and press Enter to select the first partition.
  10. Type fb and press Enter.
    • Note: fb is the hexadecimal code for VMFS volumes.
  11. Type x and press Enter to enter Expert mode.
  12. Type b and press Enter to start the process of changing the starting block of the partition.
  13. Type 1 and press Enter to select the first partition.
  14. Type 128 and press Enter to set the starting block to 128.
  15. Type w and press Enter to save the changes and exit fdisk.
  • Use the vmkfstools command to format the new partition as a VMFS-3 datastore, specifying a Block Size of 1-8MB, a friendly name for the datastore, and the chosen disk device and the created partition.

    vmkfstools -C vmfs3 -b BlockSize -S DatastoreVolumeName /vmfs/devices/disks/ DeviceName:Partition

    Usage:

    vmkfstools -C vmfs3 /vmfs/devices/disks/vml... or,
    vmkfstools -C vmfs3 /vmfs/devices/disks/naa... or,
    vmkfstools -C vmfs3 /vmfs/devices/disks/mpx.vmhbaA:T:L:P

    For example:

    vmkfstools -C vmfs3 -b 8m -S NewDatastore /vmfs/devices/disks/naa.60901234567890123456789012345678:1

    For ESXi 5.0 you can create a datastore with the VMFS-5 file system using the command:

    vmkfstools -C vmfs5 -b 1m -S NewDatastore /vmfs/devices/disks/naa.60901234567890123456789012345678:1

    Note: In a VMFS 5 file system, the recommended starting offset is 2048, instead of 128. This ensures to mitigate failures if the SCSI UNMAP command is used.
     
  • Rescan the storage subsystem to pick up the changes. The datastore should appear and be usable for virtual machine storage. For more information, see Performing a rescan of the storage on an ESX/ESXi host (1003988).



Additional Information