VMware VMFS分区及格式化

原创
2019/11/06 22:55
阅读数 5.1K

我在CentOS 7电脑上安装了VMware Workstation 15 Pro,再里面安装了VMware ESXi主机。今天,我在VMware Workstation里为这台主机添加了一块NVMe的硬盘,大小只有5G。从SSH登录进去运行命令行,看看这个ESXi主机里的操作系统上如何对磁盘进行分区和格式化。

# 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

上面使用fdisk -l查看硬盘分区信息,提示说这个命令已经过时了,要使用partedUtil对磁盘进行格式化。

另外,还看到了那块空白的磁盘,盘符看起来怪怪的。

# partedUtil
Not enough arguments

Usage:
 Get Partitions : get <diskName>

//获取磁盘的信息


 Set Partitions : set <diskName> ["partNum startSector endSector type attr"]*

//设置磁盘信息


 Delete Partition : delete <diskName> <partNum>

//删除分区: delete <磁盘名称> <磁盘编号>


 Resize Partition : resize <diskName> <partNum> <start> <end>

//重新分区: resize <diskName> <partNum> <start> <end>


 Get Partitions : getptbl <diskName>

//获取分区列表: 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

上面的这个命令在获取一个磁盘的可用扇区,34是开始,10485726是结束的扇区。

 # 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"

后面几个参数,partNum startSector endSector type/guid attr。其中:

  • partNum,分区编号是1,实际上这个磁盘只有一个分区
  • startSector:2048(VMFS 5推荐为这个值)
  • endSector: 10485726(刚才查出来的最大扇区号)
  • type/guid: AA31E02A400F11DB9590000C2911D1B8,即vmfs格式的文件系统
  • attr: 设为0

接下来,怎样格式化这块新创建的分区?

怎样查看现有分区的block size?

# partedUtil partinfo /dev/disks/t10.NVMe____VMware_Virtual_NVMe_Disk________________VMWare_NVME2D0000____00000001 1

注意上面这条命令,最后有一个1,指查看第1个分区的信息,如下:

Partition Number: 1
Start sector: 2048
End sector: 10485726
Partition Type GUID: AA31E02A400F11DB9590000C2911D1B8
Partition Unique GUID: FD3C189755D248B8916446785DCFA72A
Partition Filesystem Type: vmfs
Partition attributes: 0

格式化:

# 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

查看其block size是不是1M或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

 

创建scratch分区
 

# mkdir /vmfs/volumes/Datastore1/.scratch
# vim-cmd hostsvc/advopt/update ScratchConfig.ConfiguredScratchLocation string /vmfs/volumes/Datastore1/.scratch

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部