有时为了节省空间,把esxi安装在u盘里,有些u盘比较大,安装完成后,看不到剩余的空间了,通过一系列的设置,可以让剩余的u盘空间当做存储。
以下是在esxi6.7上面试验,已成功
一,开启esxi的ssh,用ssh登录
[root@localhost:~] cd /vmfs/devices/disks
[root@localhost:/dev/disks]
进入到磁盘目录
二,列出当前所有的磁盘
[root@localhost:/dev/disks] ls
mpx.vmhba32:C0:T0:L0
mpx.vmhba32:C0:T0:L0:1
mpx.vmhba32:C0:T0:L0:5
mpx.vmhba32:C0:T0:L0:6
mpx.vmhba32:C0:T0:L0:7
mpx.vmhba32:C0:T0:L0:8
mpx.vmhba32:C0:T0:L0:9
t10.ATA_____WDC_WD40EFRX2D68N32N0_________________________WD2DWCC7K89P8HU0
t10.ATA_____WDC_WD40EFRX2D68WT0N0_________________________WD2DWCC677YCP35U
vml.0000000000766d68626133323a303a30
vml.0000000000766d68626133323a303a30:1
vml.0000000000766d68626133323a303a30:5
vml.0000000000766d68626133323a303a30:6
vml.0000000000766d68626133323a303a30:7
vml.0000000000766d68626133323a303a30:8
vml.0000000000766d68626133323a303a30:9
vml.0100000000202020202057442d574343344537594350333555574443205744
vml.0100000000202020202057442d574343374b36545038485530574443205744
这个是u盘名字:mpx.vmhba32:C0:T0:L0
三,查看u盘的分区信息
[root@localhost:/dev/disks] partedUtil getptbl mpx.vmhba32:C0:T0:L0
gpt
15297 255 63 245760000
1 64 8191 C12A7328F81F11D2BA4B00A0C93EC93B systemPartition 128
5 8224 520191 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
6 520224 1032191 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
7 1032224 1257471 9D27538040AD11DBBF97000C2911D1B8 vmkDiagnostic 0
8 1257504 1843199 EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
9 1843200 7086079 9D27538040AD11DBBF97000C2911D1B8 vmkDiagnostic 0
请注意一个数字:245760000,将这个数字减去34,这个数字每个人不一样,用你显示的数字,减去34即可。
四,写入新的分区
partedUtil setptbl mpx.vmhba32:C0:T0:L0 gpt \
"1 64 8191 C12A7328F81F11D2BA4B00A0C93EC93B 128" \
"5 8224 520191 EBD0A0A2B9E5443387C068B6B72699C7 0" \
"6 520224 1032191 EBD0A0A2B9E5443387C068B6B72699C7 0" \
"7 1032224 1257471 9D27538040AD11DBBF97000C2911D1B8 0" \
"8 1257504 1843199 EBD0A0A2B9E5443387C068B6B72699C7 0" \
"9 1843200 7086079 9D27538040AD11DBBF97000C2911D1B8 0" \
"2 7086080 15472639 EBD0A0A2B9E5443387C068B6B72699C7 0" \
"3 15472640 245759966 AA31E02A400F11DB9590000C2911D1B8 0"
请注意最后一行的245759966,是上面数字减去34的结果,只需要更改此处就行,其它不变。复制到shell里面
五,创建分区
[root@localhost:/dev/disks] vmkfstools -C vmfs5 -b 1m -S UsbDatastore mpx.vmhba32:C0:T0:L0:3
create fs deviceName:'mpx.vmhba32:C0:T0:L0:3', fsShortName:'vmfs5', fsName:'UsbDatastore'
deviceFullPath:/dev/disks/mpx.vmhba32:C0:T0:L0:3 deviceFile:mpx.vmhba32:C0:T0:L0:3
ATS on device /dev/disks/mpx.vmhba32:C0:T0:L0:3: not supported
.
Checking if remote hosts are using this device as a valid file system. This may take a few seconds...
Creating vmfs5 file system on "mpx.vmhba32:C0:T0:L0:3" with blockSize 1048576 and volume label "UsbDatastore".
Successfully created new volume: 614c3644-0b5f4881-2bca-00e04c680479