前提
ESXi支持硬件直通(需要CPU和主板都支持VT-d),可以将PCI的硬件直接配置给虚拟机来使用。但也仅限于PCI设备,其他直接接在主板的磁盘、USB设备、CPU内置显卡等都是不能被直通的。如果希望将某个磁盘也直通给虚拟机,有两种办法:
- 添置一块PCI的阵列卡,将其直通给虚拟机,所有需要直通的磁盘都接在这个阵列卡上面;
- 创建RDM虚拟磁盘;
创建RDM虚拟磁盘
通过SSH登录ESXi,获取磁盘设备标识符:
ls -l /dev/disks
敲完命令后出来类似如下:
naa.200049454505080fnaa.200049454505080f:1 naa.200049454505080f:5naa.200049454505080f:6 naa.200049454505080f:7naa.200049454505080f:8 naa.200049454505080f:9t10.ATA_____HGST_HTS541010A9E680__________________________JD1050CCG3XJZK t10.ATA_____LITEONIT_LMT2D256M3M_____________________TW0V6PN8550852CJ1446 t10.ATA_____LITEONIT_LMT2D256M3M_____________________TW0V6PN8550852CJ1446:4 vml.01000000002020202020204a443130353043434733584a5a4b484753542048 vml.01000000005457305636504e38353530383532434a313434364c4954454f4e vml.01000000005457305636504e38353530383532434a313434364c4954454f4e:4 vml.0200000000200049454505080f4d6173732053vml.0200000000200049454505080f4d6173732053:1 vml.0200000000200049454505080f4d6173732053:5vml.0200000000200049454505080f4d6173732053:6 vml.0200000000200049454505080f4d6173732053:7vml.0200000000200049454505080f4d6173732053:8 vml.0200000000200049454505080f4d6173732053:9
其中冒号后的数字为硬盘分区。复制不带数字的标识符,如:t10.ATA_____HGST_HTS541010A9E680__________________________JD1050CCG3XJZK
执行以下命令:
vmkfstools -z /vmfs/devices/disks/<直通硬盘的标识符> /vmfs/volumes/<保存vmdk的硬盘标识符>/<VMDK名字>.vmdk
例如:
vmkfstools -z /vmfs/devices/disks/t10.ATA_____HGST_HTS541010A9E680__________________________JD1050CCG3XJZK /vmfs/volumes/5851c14c-7f3006b5-33e4-000ec4ce7958/DSMdisk.vmdk