Create VMFS Partition Using Linux for ESXi

linuxvmware-esxi

I want to create an VMFS partition on a disk using GPT. I know using esxi cli we can create it easily using partedUtil with command

partedUtil setptbl /dev/disks/t10.ATA_____SAMSUNG_MZ7LM480HMHQ2D00005 gpt "3 1547328 937703040 AA31E02A400F11DB9590000C2911D1B8 0"

but I need to create it using a rescue disk. I tried fdisk but VMFS partition type (AA31E02A400F11DB9590000C2911D1B8) is unavailable. Which tool can I use in a standard linux distribution to create VMFS partition?

Thank you

Best Answer

There's nothing special about it being a VMFS partition: you would create it the same as any other partition, but with the VMFS GUID. Note that you must format the VMFS volume from within ESXi (or using a VMWare tool). This can be destructive if you don't know what you're doing: you should read the manual first. Make sure you back up your data before manipulating or formatting partitions.

For example, using gdisk:

squircle@weber:~$ sudo gdisk /dev/loop0                                                                     [5/191]
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-2097118, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-2097118, default = 2097118) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): fb00
Changed type of partition to 'VMWare VMFS'

Command (? for help): p
Disk /dev/loop0: 2097152 sectors, 1024.0 MiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 427EF575-E04D-4C65-8AF6-66CB127F0AE0
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 2097118
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2097118   1023.0 MiB  FB00  VMWare VMFS

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/loop0.

Note that gdisk uses filesystem code fb00 to refer to the VMWare VMFS GUID, but you can also type the full GUID if you wish. Make sure to change the partition location if your disk already has data on it.

You can verify that the partition has the correct GUID using the same family of utilities:

squircle@weber:~$ sudo sgdisk -i 1 /dev/loop0 | head -n 1
Partition GUID code: AA31E02A-400F-11DB-9590-000C2911D1B8 (VMWare VMFS)