如果你只想直通单个硬盘,而不是整个 SATA 控制器,也可以使用 RDM (Raw Device Mapping) 功能直接将磁盘分配给虚拟机。
或者是你的控制器不支持直通,也可以用这种方法将所有的硬盘直接分配给虚拟机使用。
1、创建一个专门用来存储 RDM 映射文件的目录
mkdir /vmfs/volumes/datastore1/passthru_disks
2、查看本机识别到的磁盘,t10 开头或者是 naa开头(这里把分区也列出来了,结尾是冒号加数字的就是分区,此处只看磁盘不看分区)
[root@localhost:/dev/disks] ls -l /vmfs/devices/disks/ total 7575766936 -rw------- 1 root root 2000398934016 Dec 23 03:47 t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E2PVS2 -rw------- 1 root root 2000397795328 Dec 23 03:47 t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E2PVS2:1 -rw------- 1 root root 1000204886016 Dec 23 03:47 t10.ATA_____TOSHIBA_DT01ACA100_________________________________97BD6G2MS -rw------- 1 root root 1000204886016 Dec 23 03:47 t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68G9BHNS -rw------- 1 root root 1000204886016 Dec 23 03:47 t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68GBZXNS -rw------- 1 root root 500107862016 Dec 23 03:47 t10.ATA_____WDC_WD5000AAKX2D75U6AA0_______________________WD2DWCC2E5EKA3KR -rw------- 1 root root 128035676160 Dec 23 03:47 t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF -rw------- 1 root root 104857600 Dec 23 03:47 t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:1 -rw------- 1 root root 4293918720 Dec 23 03:47 t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:5 -rw------- 1 root root 4293918720 Dec 23 03:47 t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:6 -rw------- 1 root root 4294967296 Dec 23 03:47 t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:7 -rw------- 1 root root 115042754048 Dec 23 03:47 t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:8 lrwxrwxrwx 1 root root 73 Dec 23 03:47 vml.01000000002020202020202020202020205a31453250565332535432303030 -> t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E2PVS2 lrwxrwxrwx 1 root root 75 Dec 23 03:47 vml.01000000002020202020202020202020205a31453250565332535432303030:1 -> t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E2PVS2:1 lrwxrwxrwx 1 root root 72 Dec 23 03:47 vml.01000000002020202020202020202020393742443647324d53544f53484942 -> t10.ATA_____TOSHIBA_DT01ACA100_________________________________97BD6G2MS lrwxrwxrwx 1 root root 72 Dec 23 03:47 vml.01000000002020202020202020202020593638473942484e53544f53484942 -> t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68G9BHNS lrwxrwxrwx 1 root root 72 Dec 23 03:47 vml.0100000000202020202020202020202059363847425a584e53544f53484942 -> t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68GBZXNS lrwxrwxrwx 1 root root 74 Dec 23 03:47 vml.0100000000202020202057442d574343324535454b41334b52574443205744 -> t10.ATA_____WDC_WD5000AAKX2D75U6AA0_______________________WD2DWCC2E5EKA3KR lrwxrwxrwx 1 root root 68 Dec 23 03:47 vml.0100000000464646465f464646465f464646465f4646464600424337313120 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.0100000000464646465f464646465f464646465f4646464600424337313120:1 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:1 lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.0100000000464646465f464646465f464646465f4646464600424337313120:5 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:5 lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.0100000000464646465f464646465f464646465f4646464600424337313120:6 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:6 lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.0100000000464646465f464646465f464646465f4646464600424337313120:7 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:7 lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.0100000000464646465f464646465f464646465f4646464600424337313120:8 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:8 lrwxrwxrwx 1 root root 68 Dec 23 03:47 vml.050a4893a9a48fee95b6e22209f44af93d689b6e12d283b752116b126ff67d4717 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.050a4893a9a48fee95b6e22209f44af93d689b6e12d283b752116b126ff67d4717:1 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:1 lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.050a4893a9a48fee95b6e22209f44af93d689b6e12d283b752116b126ff67d4717:5 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:5 lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.050a4893a9a48fee95b6e22209f44af93d689b6e12d283b752116b126ff67d4717:6 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:6 lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.050a4893a9a48fee95b6e22209f44af93d689b6e12d283b752116b126ff67d4717:7 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:7 lrwxrwxrwx 1 root root 70 Dec 23 03:47 vml.050a4893a9a48fee95b6e22209f44af93d689b6e12d283b752116b126ff67d4717:8 -> t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF:8
3、创建 RDM 映射文件(因为做的盘比较多,特意在RDM映射文件的名字中标注了盘的品牌型号和SN,方便后面维护和使用)
vmkfstools -z /vmfs/devices/disks/t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E2PVS2 /vmfs/volumes/datastore1/passthru_disks/ST2000DM_Z1E2PVS2.vmdk vmkfstools -z /vmfs/devices/disks/t10.ATA_____TOSHIBA_DT01ACA100_________________________________97BD6G2MS /vmfs/volumes/datastore1/passthru_disks/TOSHIBA_97BD6G2MS.vmdk vmkfstools -z /vmfs/devices/disks/t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68G9BHNS /vmfs/volumes/datastore1/passthru_disks/TOSHIBA_Y68G9BHNS.vmdk vmkfstools -z /vmfs/devices/disks/t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68GBZXNS /vmfs/volumes/datastore1/passthru_disks/TOSHIBA_Y68GBZXNS.vmdk vmkfstools -z /vmfs/devices/disks/t10.ATA_____WDC_WD5000AAKX2D75U6AA0_______________________WD2DWCC2E5EKA3KR /vmfs/volumes/datastore1/passthru_disks/WDC_WD5000_EKA3KR.vmdk
4、在命令行查看创建好的 RDM 映射文件,一长一短两个文件,在使用的时候我们只使用短的文件名,but长文件的也不要删除哦。
[root@localhost:~] ls -l /vmfs/volumes/datastore1/passthru_disks total 0 -rw------- 1 root root 2000398934016 Dec 23 03:48 ST2000DM_Z1E2PVS2-rdmp.vmdk -rw------- 1 root root 487 Dec 23 03:48 ST2000DM_Z1E2PVS2.vmdk -rw------- 1 root root 1000204886016 Dec 23 03:49 TOSHIBA_97BD6G2MS-rdmp.vmdk -rw------- 1 root root 487 Dec 23 03:49 TOSHIBA_97BD6G2MS.vmdk -rw------- 1 root root 1000204886016 Dec 23 03:49 TOSHIBA_Y68G9BHNS-rdmp.vmdk -rw------- 1 root root 487 Dec 23 03:49 TOSHIBA_Y68G9BHNS.vmdk -rw------- 1 root root 1000204886016 Dec 23 03:49 TOSHIBA_Y68GBZXNS-rdmp.vmdk -rw------- 1 root root 487 Dec 23 03:49 TOSHIBA_Y68GBZXNS.vmdk -rw------- 1 root root 500107862016 Dec 23 03:49 WDC_WD5000_EKA3KR-rdmp.vmdk -rw------- 1 root root 485 Dec 23 03:49 WDC_WD5000_EKA3KR.vmdk
补充:在查询磁盘信息的时候,还可以使用命令 esxcli storage core device list
[root@localhost:/dev/disks] esxcli storage core device list t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E2PVS2Display Name: Local ATA Disk (t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E2PVS2)Has Settable Display Name: trueSize: 1907729Device Type: Direct-AccessMultipath Plugin: HPPDevfs Path: /vmfs/devices/disks/t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E2PVS2Vendor: ATAModel: ST2000DM001-1CH1Revision: CC24SCSI Level: 5Is Pseudo: falseStatus: onIs RDM Capable: falseIs Local: trueIs Removable: falseIs SSD: falseIs VVOL PE: falseIs Offline: falseIs Perennially Reserved: falseQueue Full Sample Size: 0Queue Full Threshold: 0Thin Provisioning Status: unknownAttached Filters:VAAI Status: unsupportedOther UIDs: vml.01000000002020202020202020202020205a31453250565332535432303030Is Shared Clusterwide: falseIs SAS: falseIs USB: falseIs Boot Device: falseDevice Max Queue Depth: 31No of outstanding IOs with competing worlds: 31Drive Type: unknownRAID Level: unknownNumber of Physical Drives: unknownProtection Enabled: falsePI Activated: falsePI Type: 0PI Protection Mask: NO PROTECTIONSupported Guard Types: NO GUARD SUPPORTDIX Enabled: falseDIX Guard Type: NO GUARD SUPPORTEmulated DIX/DIF Enabled: falset10.ATA_____TOSHIBA_DT01ACA100_________________________________97BD6G2MSDisplay Name: Local ATA Disk (t10.ATA_____TOSHIBA_DT01ACA100_________________________________97BD6G2MS)Has Settable Display Name: trueSize: 953869Device Type: Direct-AccessMultipath Plugin: HPPDevfs Path: /vmfs/devices/disks/t10.ATA_____TOSHIBA_DT01ACA100_________________________________97BD6G2MSVendor: ATAModel: TOSHIBA DT01ACA1Revision: A810SCSI Level: 5Is Pseudo: falseStatus: onIs RDM Capable: falseIs Local: trueIs Removable: falseIs SSD: falseIs VVOL PE: falseIs Offline: falseIs Perennially Reserved: falseQueue Full Sample Size: 0Queue Full Threshold: 0Thin Provisioning Status: unknownAttached Filters:VAAI Status: unsupportedOther UIDs: vml.01000000002020202020202020202020393742443647324d53544f53484942Is Shared Clusterwide: falseIs SAS: falseIs USB: falseIs Boot Device: falseDevice Max Queue Depth: 31No of outstanding IOs with competing worlds: 31Drive Type: unknownRAID Level: unknownNumber of Physical Drives: unknownProtection Enabled: falsePI Activated: falsePI Type: 0PI Protection Mask: NO PROTECTIONSupported Guard Types: NO GUARD SUPPORTDIX Enabled: falseDIX Guard Type: NO GUARD SUPPORTEmulated DIX/DIF Enabled: falset10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68GBZXNSDisplay Name: Local ATA Disk (t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68GBZXNS)Has Settable Display Name: trueSize: 953869Device Type: Direct-AccessMultipath Plugin: HPPDevfs Path: /vmfs/devices/disks/t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68GBZXNSVendor: ATAModel: TOSHIBA DT01ACA1Revision: A800SCSI Level: 5Is Pseudo: falseStatus: onIs RDM Capable: falseIs Local: trueIs Removable: falseIs SSD: falseIs VVOL PE: falseIs Offline: falseIs Perennially Reserved: falseQueue Full Sample Size: 0Queue Full Threshold: 0Thin Provisioning Status: unknownAttached Filters:VAAI Status: unsupportedOther UIDs: vml.0100000000202020202020202020202059363847425a584e53544f53484942Is Shared Clusterwide: falseIs SAS: falseIs USB: falseIs Boot Device: falseDevice Max Queue Depth: 31No of outstanding IOs with competing worlds: 31Drive Type: unknownRAID Level: unknownNumber of Physical Drives: unknownProtection Enabled: falsePI Activated: falsePI Type: 0PI Protection Mask: NO PROTECTIONSupported Guard Types: NO GUARD SUPPORTDIX Enabled: falseDIX Guard Type: NO GUARD SUPPORTEmulated DIX/DIF Enabled: falset10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68G9BHNSDisplay Name: Local ATA Disk (t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68G9BHNS)Has Settable Display Name: trueSize: 953869Device Type: Direct-AccessMultipath Plugin: HPPDevfs Path: /vmfs/devices/disks/t10.ATA_____TOSHIBA_DT01ACA100_________________________________Y68G9BHNSVendor: ATAModel: TOSHIBA DT01ACA1Revision: A800SCSI Level: 5Is Pseudo: falseStatus: onIs RDM Capable: falseIs Local: trueIs Removable: falseIs SSD: falseIs VVOL PE: falseIs Offline: falseIs Perennially Reserved: falseQueue Full Sample Size: 0Queue Full Threshold: 0Thin Provisioning Status: unknownAttached Filters:VAAI Status: unsupportedOther UIDs: vml.01000000002020202020202020202020593638473942484e53544f53484942Is Shared Clusterwide: falseIs SAS: falseIs USB: falseIs Boot Device: falseDevice Max Queue Depth: 31No of outstanding IOs with competing worlds: 31Drive Type: unknownRAID Level: unknownNumber of Physical Drives: unknownProtection Enabled: falsePI Activated: falsePI Type: 0PI Protection Mask: NO PROTECTIONSupported Guard Types: NO GUARD SUPPORTDIX Enabled: falseDIX Guard Type: NO GUARD SUPPORTEmulated DIX/DIF Enabled: falset10.ATA_____WDC_WD5000AAKX2D75U6AA0_______________________WD2DWCC2E5EKA3KRDisplay Name: Local ATA Disk (t10.ATA_____WDC_WD5000AAKX2D75U6AA0_______________________WD2DWCC2E5EKA3KR)Has Settable Display Name: trueSize: 476940Device Type: Direct-AccessMultipath Plugin: HPPDevfs Path: /vmfs/devices/disks/t10.ATA_____WDC_WD5000AAKX2D75U6AA0_______________________WD2DWCC2E5EKA3KRVendor: ATAModel: WDC WD5000AAKX-7Revision: 1H20SCSI Level: 5Is Pseudo: falseStatus: onIs RDM Capable: falseIs Local: trueIs Removable: falseIs SSD: falseIs VVOL PE: falseIs Offline: falseIs Perennially Reserved: falseQueue Full Sample Size: 0Queue Full Threshold: 0Thin Provisioning Status: unknownAttached Filters:VAAI Status: unsupportedOther UIDs: vml.0100000000202020202057442d574343324535454b41334b52574443205744Is Shared Clusterwide: falseIs SAS: falseIs USB: falseIs Boot Device: falseDevice Max Queue Depth: 31No of outstanding IOs with competing worlds: 31Drive Type: unknownRAID Level: unknownNumber of Physical Drives: unknownProtection Enabled: falsePI Activated: falsePI Type: 0PI Protection Mask: NO PROTECTIONSupported Guard Types: NO GUARD SUPPORTDIX Enabled: falseDIX Guard Type: NO GUARD SUPPORTEmulated DIX/DIF Enabled: falset10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFFDisplay Name: Local NVMe Disk (t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFF)Has Settable Display Name: trueSize: 122104Device Type: Direct-AccessMultipath Plugin: HPPDevfs Path: /vmfs/devices/disks/t10.NVMe____BC711_NVMe_SK_hynix_128GB_______________FFFFFFFFFFFFFFFFVendor: NVMeModel: BC711 NVMe SK hyRevision: 4100SCSI Level: 6Is Pseudo: falseStatus: onIs RDM Capable: falseIs Local: trueIs Removable: falseIs SSD: trueIs VVOL PE: falseIs Offline: falseIs Perennially Reserved: falseQueue Full Sample Size: 0Queue Full Threshold: 0Thin Provisioning Status: yesAttached Filters:VAAI Status: unsupportedOther UIDs: vml.050a4893a9a48fee95b6e22209f44af93d689b6e12d283b752116b126ff67d4717Is Shared Clusterwide: falseIs SAS: falseIs USB: falseIs Boot Device: trueDevice Max Queue Depth: 1023No of outstanding IOs with competing worlds: 32Drive Type: unknownRAID Level: unknownNumber of Physical Drives: unknownProtection Enabled: falsePI Activated: falsePI Type: 0PI Protection Mask: NO PROTECTIONSupported Guard Types: NO GUARD SUPPORTDIX Enabled: falseDIX Guard Type: NO GUARD SUPPORTEmulated DIX/DIF Enabled: false