I installed VMware Workstation 15 Pro on a CentOS 7 computer and installed a VMware ESXi host on it. Today, I added an NVMe hard drive to this host in VMware Workstation, the size is only 5G. Log in from SSH and run the command line to see how the disk is partitioned and formatted on the OS on this ESXi host.
# df -h
//看到了如下的结果:
Filesystem Size Used Available Use% Mounted on
VMFS-6 142.5G 84.8G 57.7G 60% /vmfs/volumes/datastore1
vfat 249.7M 155.2M 94.6M 62% /vmfs/volumes/0ef1c67e-54175993-9656-932280ba9446
vfat 285.8M 172.9M 112.9M 60% /vmfs/volumes/5d653d0f-64439c8c-7b4c-000c298b51e3
vfat 249.7M 146.5M 103.2M 59% /vmfs/volumes/3e062d7e-1ad90a51-07ec-d5b812fdb036
vfat 4.0G 33.2M 4.0G 1% /vmfs/volumes/5d653d15-461dfccc-77a2-000c298b51e3
[root@172:~] fdisk -l
***
*** The fdisk command is deprecated: fdisk does not handle GPT partitions. Please use partedUtil
***
Found valid GPT with protective MBR; using GPT
Disk /dev/disks/mpx.vmhba0:C0:T0:L0: 629145600 sectors, 0
Logical sector size: 512
Disk identifier (GUID): 5e307c8f-fd9c-488d-b3bc-d83d6fbd4321
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 629145566
Number Start (sector) End (sector) Size Name
1 64 8191 4064K
2 7086080 15472639 4095M
3 15472640 314572766 142G
5 8224 520191 249M
6 520224 1032191 249M
7 1032224 1257471 109M
8 1257504 1843199 285M
9 1843200 7086079 2560M
Disk /dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001: 5120 MB, 5368709120 bytes, 10485760 sectors
652 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes
Disk /dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001 doesn't contain a valid partition table
The above use fdisk -l to view the hard disk partition information, and it is prompted that this command is outdated, and partedUtil should be used to format the disk.
In addition, I also saw the blank disk, and the drive letter looked strange.
# partedUtil
Not enough arguments
Usage:
Get Partitions : get <diskName>
//get disk information
Set Partitions : set <diskName> ["partNum startSector endSector type attr"]*
// set disk information
Delete Partition : delete <diskName> <partNum>
//Delete partition: delete <disk name> <disk number>
Resize Partition : resize <diskName> <partNum> <start> <end>
//重新分区: resize <diskName> <partNum> <start> <end>
Get Partitions : getptbl <diskName>
//Get the list of partitions: getptbl <diskName>
Set Partitions : setptbl <diskName> <label> ["partNum startSector endSector type/guid attr"]*
Fix Partition Table : fix <diskName>
Create New Label (all existing data will be lost): mklabel <diskName> <label>
Show commonly used partition type guids : showGuids
Get usable first and last sectors : getUsableSectors <diskName>
# partedUtil getUsableSectors /dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001
34 10485726
The above command is getting the free sectors of a disk, 34 is the beginning, and 10485726 is the ending sector.
# partedUtil showGuids
//命令显示常见的分区类型及其GUID编号
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
Fix GPT Table interactively : fixGpt <diskName>
Show Partition Information : partinfo <diskName> <partNum>
Add Partition Information : add <diskName> <label> ["partNum startSector endSector type/guid attr"]
# partedUtil add /dev/disks
/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001 gpt "1 2048 10485726 AA31E02A400F11DB9590000C2911D1B8 0"
The following parameters, partNum startSector endSector type/guid attr. in:
- partNum, the partition number is 1, in fact this disk has only one partition
- startSector: 2048 (recommended for VMFS 5)
- endSector: 10485726 (the largest sector number found just now)
- type/guid: AA31E02A400F11DB9590000C2911D1B8, the file system in vmfs format
- attr: set to 0
Next, how to format this newly created partition?
How to check the block size of an existing partition?
# partedUtil partinfo /dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001 1
Note that in the above command, there is a 1 at the end, which means to view the information of the first partition, as follows:
Partition Number: 1
Start sector: 2048
End sector: 10485726
Partition Type GUID: AA31E02A400F11DB9590000C2911D1B8
Partition Unique GUID: FD3C189755D248B8916446785DCFA72A
Partition Filesystem Type: vmfs
Partition attributes: 0
format:
# vmkfstools -C vmfs6 /dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001:1
create fs deviceName:'/dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001:1', fsShortName:'vmfs6', fsName:'(null)'
deviceFullPath:/dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001:1 deviceFile:t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001:1
ATS on device /dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001: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 "t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001:1" with blockSize 1048576, unmapGranularity 1048576, unmapPriority default and volume label "none".
Successfully created new volume: 5dc2f1b6-5f9057e0-b194-000c298b51e3
Check if its block size is 1M or 512M:
# vmkfstools -P -v10 /dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001
Could not retrieve max file size: Function not implemented
devfs-1.00 (Raw Major Version: 0) file system spanning 0 partitions.
File system label (if any):
Mode: private
Capacity 512 (1 file blocks * 512), 512 (1 blocks) avail, max supported file size 0
Disk Block Size: 512/512/0
UUID: 00000000-00000000-0000-000000000000
Logical device:
Partitions spanned (on "notDCS"):
Is Native Snapshot Capable: NO
OBJLIB-LIB: ObjLib cleanup done.
WORKER: asyncOps=0 maxActiveOps=0 maxPending=0 maxCompleted=0
vmkfstools -P -v10 -h /vmfs/volumes/datastore1
VMFS-6.82 (Raw Major Version: 24) file system spanning 1 partitions.
File system label (if any): datastore1
Mode: public
Capacity 142.5 GB, 57.7 GB available, file block size 1 MB, max supported file size 64 TB
Volume Creation Time: Tue Aug 27 14:24:21 2019
Files (max/free): 16384/16291
Ptr Blocks (max/free): 0/0
Sub Blocks (max/free): 16384/16313
Secondary Ptr Blocks (max/free): 256/255
File Blocks (overcommit/used/overcommit %): 0/86873/0
Ptr Blocks (overcommit/used/overcommit %): 0/0/0
Sub Blocks (overcommit/used/overcommit %): 0/71/0
Large File Blocks (total/used/file block clusters): 285/118/128
Volume Metadata size: 1504681984
Disk Block Size: 512/512/0
UUID: 5d653d15-3352555a-55d3-000c298b51e3
Logical device: 5d653d15-27d81446-5f1d-000c298b51e3
Partitions spanned (on "lvm"):
mpx.vmhba0:C0:T0:L0:3
Is Native Snapshot Capable: NO
OBJLIB-LIB: ObjLib cleanup done.
WORKER: asyncOps=0 maxActiveOps=0 maxPending=0 maxCompleted=0
Create scratch partition
# mkdir /vmfs/volumes/Datastore1/.scratch
# vim-cmd hostsvc/advopt/update ScratchConfig.ConfiguredScratchLocation string /vmfs/volumes/Datastore1/.scratch