ESXi 7: Create VMFS Partition Via Command Line

root's picture

I attached a disk one day and was impossible to create datastore on it via web interface.
Well, did not thought much about it and went directly on command line, via ssh and if you are curious, please follow.

Check out my channel for other interesting videos.

1. Get the partition table information:

[root@eeny:~] partedUtil "getptbl" /vmfs/devices/disks/mpx.vmhba34\:C0\:T0\:L0 
gpt
364801 255 63 5860533168

2. Get the end sector value:

NOTE: start sector value is 2048

[root@eeny:~] eval expr $(partedUtil getptbl "/vmfs/devices/disks/mpx.vmhba34:C0:T0:L0" | tail -1 | awk '{print $1 " \\* " $2 " \\* " $3}')
5860528065

3. Get GUID for vmfs:

[root@eeny:~] partedUtil showGuids
 Partition Type       GUID
 vmfs                 AA31E02A400F11DB9590000C2911D1B8
 vmkDiagnostic        9D27538040AD11DBBF97000C2911D1B8
 vsan                 381CFCCC728811E092EE000C2911D0B2
 virsto               77719A0CA4A011E3A47E000C29745A24
 VMware Reserved      9198EFFC31C011DB8F78000C2911D1B8
 Basic Data           EBD0A0A2B9E5443387C068B6B72699C7
 Linux Swap           0657FD6DA4AB43C484E50933C84B4F4F
 Linux Lvm            E6D6D379F50744C2A23C238F2A3DF928
 Linux Raid           A19D880F05FC4D3BA006743F0F84911E
 Efi System           C12A7328F81F11D2BA4B00A0C93EC93B
 Microsoft Reserved   E3C9E3160B5C4DB8817DF92DF00215AE
 Unused Entry         00000000000000000000000000000000

4. Create VMFS partition:

[root@eeny:~] partedUtil setptbl /vmfs/devices/disks/mpx.vmhba34\:C0\:T0\:L0 gpt "1 2048 5860528065 AA31E02A400F11DB9590000C2911D1B8 0"
gpt
0 0 0 0
1 2048 5860528065 AA31E02A400F11DB9590000C2911D1B8 0

5. Format VMFS partition and give it a name too:

[root@eeny:~] vmkfstools -C vmfs6 -S WD101 "/vmfs/devices/disks/mpx.vmhba34:C0:T0:L0:1"
create fs deviceName:'/vmfs/devices/disks/mpx.vmhba34:C0:T0:L0:1', fsShortName:'vmfs6', fsName:'WD101'
deviceFullPath:/dev/disks/mpx.vmhba34:C0:T0:L0:1 deviceFile:mpx.vmhba34:C0:T0:L0:1
ATS on device /dev/disks/mpx.vmhba34:C0:T0:L0:1: not supported
.
Checking if remote hosts are using this device as a valid file system. This may take a few seconds...
Creating vmfs6 file system on "mpx.vmhba34:C0:T0:L0:1" with blockSize 1048576, unmapGranularity 1048576, unmapPriority default and volume label "WD101".
Successfully created new volume: 61534d15-487271ca-337d-a8206611bd75

And done!

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content

root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root