{"id":383,"date":"2025-05-18T15:12:43","date_gmt":"2025-05-18T07:12:43","guid":{"rendered":"https:\/\/cliyr.cn\/?p=383"},"modified":"2025-05-18T15:12:43","modified_gmt":"2025-05-18T07:12:43","slug":"pve%e9%a3%9e%e7%89%9b%e7%a1%ac%e7%9b%98%e7%9b%b4%e9%80%9a","status":"publish","type":"post","link":"https:\/\/cliyr.cn\/?p=383","title":{"rendered":"PVE\u98de\u725b\u786c\u76d8\u76f4\u901a"},"content":{"rendered":"\n<p>\u5f00\u542fiommu\u76f4\u901a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nano \/etc\/modprobe.d\/kvm.conf\noptions kvm ignore_msrs=Y report_ignored_msrs=0\n# \u6309 Ctrl + X\uff0c\u7136\u540e\u6309 Y + Enter \u4fdd\u5b58\u66f4\u6539\u3002<\/pre>\n\n\n\n<p><strong>\u542f\u52a8\u5185\u6838IOMMU\u652f\u6301<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nano \/etc\/default\/grub # \u5c06\u4ee5\u4e0b\u884c\u7c98\u8d34\u5230\u5176\u4e2d\uff0c\u5e76\u5728\u65e7\u6807\u7b7e\u524d\u9762\u6dfb\u52a0\u4e00\u4e2a\u6ce8\u91ca\u6807\u7b7e#,\u4ee5\u4e0b\u4e3a\u5e38\u7528\u7684\u4e00\u4e9b\u5199\u6cd5\u3002\n# \u5bf9\u4e8e Intel CPU\nGRUB_CMDLINE_LINUX_DEFAULT=\"quiet intel_iommu=on iommu=pt initcall_blacklist=sysfb_init pcie_acs_override=downstream,multifunction pci=nommconf\"\n# \u5bf9\u4e8e AMD CPU (\u672c\u6587\u4e0d\u6d89\u53ca)\nGRUB_CMDLINE_LINUX_DEFAULT=\"quiet iommu=pt initcall_blacklist=sysfb_init pcie_acs_override=downstream,multifunction pci=nommconf\"\n# \u5176\u4ed6\u7684\u4e00\u4e9b\u5199\u6cd5(\u5982\u679c\u662fAMD\u5904\u7406\u5668,\u5c06intel\u6539\u4e3aamd)\nGRUB_CMDLINE_LINUX_DEFAULT=\"quiet intel_iommu=on iommu=pt i915.enable_gvt=1 video=efifb:off\" # \u8fd9\u662fGVT\u6a21\u5f0f\uff0c\u4e5f\u5c31\u662f\u5171\u4eab\u6a21\u5f0f\uff0c\u5c11\u90e8\u5206cpu\u652f\u6301\uff0c\u4f46\u4f53\u9a8c\u5f88\u597d\nGRUB_CMDLINE_LINUX_DEFAULT=\"quiet intel_iommu=on iommu=pt video=efifb:off\" # \u8fd9\u662f\u72ec\u5360\u6a21\u5f0f\uff0c\u90fd\u652f\u6301\uff0c\u4f46\u663e\u793a\u5668\u6ca1\u6709pve\u7684\u63a7\u5236\u53f0\u8f93\u51fa\uff0c\u4e5f\u53ea\u80fd\u76f4\u901a\u4e2a\u4e00\u4e2a\u865a\u62df\u673a\nGRUB_CMDLINE_LINUX_DEFAULT=\"quiet intel_iommu=on iommu=pt pcie_acs_override=downstream,multifunction\"\nGRUB_CMDLINE_LINUX_DEFAULT=\"quiet intel_iommu=on initcall_blacklist=sysfb_init pcie_acs_override=downstream,multifunction\"\nGRUB_CMDLINE_LINUX_DEFAULT=\"quiet intel_iommu=on\" #\u672c\u671f\u6559\u7a0b\u6211\u4f7f\u7528\u7684\u5c31\u662f\u8fd9\u4e2a\n# \u53c2\u6570\u91ca\u4e49\n1.iommu=pt\uff1a\u542f\u7528 Intel VT-d \u6216 AMD-Vi \u7684 IOMMU\u3002\u8fd9\u662f\u4e00\u79cd\u786c\u4ef6\u529f\u80fd\uff0c\u7528\u4e8e\u7ba1\u7406\u8bbe\u5907\u5bf9\u7cfb\u7edf\u5185\u5b58\u7684\u8bbf\u95ee\u3002\u5728\u865a\u62df\u5316\u73af\u5883\u4e2d\uff0c\u542f\u7528 IOMMU \u540e\uff0c\u53ef\u4ee5\u5c06\u7269\u7406\u8bbe\u5907\u76f4\u901a\u5230\u865a\u62df\u673a\u4e2d\uff0c\u4ee5\u4fbf\u865a\u62df\u673a\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u786c\u4ef6\u8bbe\u5907\u3002\u201ciommu=pt\u201d\u4e0d\u662f\u5fc5\u987b\u7684\uff0cPT\u6a21\u5f0f\u53ea\u5728\u5fc5\u8981\u7684\u65f6\u5019\u5f00\u542f\u8bbe\u5907\u7684IOMMU\u8f6c\u6362\uff0c\u53ef\u4ee5\u63d0\u9ad8\u672a\u76f4\u901a\u8bbe\u5907PCIe\u7684\u6027\u80fd\uff0c\u5efa\u8bae\u6dfb\u52a0\u3002\n2.initcall_blacklist=sysfb_init\uff1a\u7981\u7528 sysfb_init \u5185\u6838\u521d\u59cb\u5316\u51fd\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u5728\u5185\u6838\u542f\u52a8\u8fc7\u7a0b\u4e2d\u521d\u59cb\u5316\u7cfb\u7edf\u5e27\u7f13\u51b2\u3002\u5728\u4f7f\u7528 GPU \u76f4\u901a\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e2a\u51fd\u6570\u53ef\u80fd\u4f1a\u5e72\u6270\u76f4\u901a\u64cd\u4f5c\uff0c\u56e0\u6b64\u9700\u8981\u7981\u7528\u5b83\u3002\n3.i915.enable_gvt=1\uff1a\u542f\u7528 Intel GVT-g \u865a\u62df GPU \u6280\u672f\u3002\u8fd9\u4e2a\u9009\u9879\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u7684 Intel GPU \u8bbe\u5907\uff0c\u4ee5\u4fbf\u591a\u4e2a\u865a\u62df\u673a\u53ef\u4ee5\u5171\u4eab\u7269\u7406 GPU \u8bbe\u5907\u3002\u542f\u7528 GVT-g \u9700\u8981\u5728\u652f\u6301\u865a\u62df GPU \u7684 Intel CPU \u548c\u4e3b\u677f\u4e0a\u8fd0\u884c\uff0c\u5e76\u4e14\u9700\u8981\u6b63\u786e\u914d\u7f6e\u5185\u6838\u548c\u865a\u62df\u673a\u3002\u60f3\u5f00\u542fGVT-g\u7684\u5c31\u6dfb\u52a0\u8fd9\u6761\uff0c\u663e\u5361\u76f4\u901a\u7684\u5c31\u4e0d\u8981\u6dfb\u52a0\u4e86\u3002\n4.initcall_blacklist=sysfb_init\uff1a\u5c4f\u853d\u6389pve7.2\u4ee5\u4e0a\u7684\u4e00\u4e2abug\uff0c\u65b9\u4fbf\u542f\u52a8\u65f6\u5019\u5c31\u5c4f\u853d\u6838\u663e\u7b49\u8bbe\u5907\u9a71\u52a8\uff1b\n5.pcie_acs_override=downstream,multifunction\uff1a\u4fbf\u4e8eiommu\u6bcf\u4e2a\u8bbe\u5907\u5355\u72ec\u5206\u7ec4\uff0c\u4ee5\u514d\u76f4\u901a\u5bfc\u81f4\u7269\u7406\u673a\u5361\u6b7b\u7b49\u95ee\u9898\n6.pci=nommconf\uff1a\u610f\u601d\u662f\u7981\u7528pci\u914d\u7f6e\u7a7a\u95f4\u7684\u5185\u5b58\u6620\u5c04,\u6240\u6709\u7684 PCI \u8bbe\u5907\u90fd\u6709\u4e00\u4e2a\u63cf\u8ff0\u8be5\u8bbe\u5907\u7684\u533a\u57df\uff08\u60a8\u53ef\u4ee5\u770b\u5230lspci -vv\uff09\uff0c\u8bbf\u95ee\u8be5\u533a\u57df\u7684\u6700\u521d\u65b9\u6cd5\u662f\u901a\u8fc7 I\/O \u7aef\u53e3\uff0c\u800c PCIe \u5141\u8bb8\u5c06\u6b64\u7a7a\u95f4\u6620\u5c04\u5230\u5185\u5b58\u4ee5\u4fbf\u66f4\u7b80\u5355\u5730\u8bbf\u95ee\u3002<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">update-grub\nreboot\ndmesg | grep -e DMAR -e IOMMU -e AMD-Vi\n# \u5982\u679c\u6ca1\u6709\u8f93\u51fa\uff0c\u5219\u8bf4\u660e\u6709\u95ee\u9898\u3002\u4f60\u5e94\u8be5\u770b\u5230\u8fd9\u6837\u7684\u4e1c\u897f\uff1b\u201cDMAR: IOMMU enabled\u201d\n# \u53e6\u5916\u4e00\u79cd\u9a8c\u8bc1\u65b9\u5f0f\ndmesg | grep iommu\n# \u51fa\u73b0\u5982\u4e0b\u4f8b\u5b50\u3002\u5219\u4ee3\u8868\u6210\u529f\n[ 1.341100] pci 0000:00:00.0: Adding to iommu group 0\n[ 1.341116] pci 0000:00:01.0: Adding to iommu group 1\n[ 1.341126] pci 0000:00:02.0: Adding to iommu group 2\n[ 1.341137] pci 0000:00:14.0: Adding to iommu group 3\n[ 1.341146] pci 0000:00:17.0: Adding to iommu group 4\n# \u6b64\u65f6\u8f93\u5165\u547d\u4ee4\nfind \/sys\/kernel\/iommu_groups\/ -type l\n# \u51fa\u73b0\u5f88\u591a\u76f4\u901a\u7ec4\uff0c\u5c31\u4ee3\u8868\u6210\u529f\u4e86\u3002\u5982\u679c\u6ca1\u6709\u4efb\u4f55\u4e1c\u897f\uff0c\u5c31\u662f\u6ca1\u6709\u5f00\u542f\n\n\n\n<\/pre>\n\n\n\n<p><strong>\u5141\u8bb8\u4e0d\u5b89\u5168\u4e2d\u65ad<\/strong><\/p>\n\n\n\n<p id=\"block-27565855-8846-45eb-b1c6-e3111822a661\">nano \/etc\/modprobe.d\/iommu_unsafe_interrupts.conf # \u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1b\u8bf7\u6ce8\u610f\uff0c\u6b64\u9009\u9879\u53ef\u80fd\u4f1a\u4f7f\u60a8\u7684\u7cfb\u7edf\u4e0d\u7a33\u5b9a\u3002\n<br>options vfio_iommu_type1 allow_unsafe_interrupts=1<\/p>\n\n\n\n<p><strong>\u542f\u7528\u5fc5\u8981\u7684\u5185\u6838\u6a21\u5757<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nano \/etc\/modules # \u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1b\nvfio\nvfio_iommu_type1\nvfio_pci\nvfio_virqfd<\/pre>\n\n\n\n<p><strong>\u5c06\u9a71\u52a8\u7a0b\u5e8f\u6a21\u5757\u5217\u5165\u9ed1\u540d\u5355\uff0c\u4ee5\u4f7f\u865a\u62df\u673a\u80fd\u591f\u5b8c\u5168\u8bbf\u95ee\u663e\u5361\u7b49<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nano \/etc\/modprobe.d\/pve-blacklist.conf # \u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1b\nblacklist nouveau\nblacklist nvidia\nblacklist nvidiafb\nblacklist snd_hda_codec_hdmi\nblacklist snd_hda_intel\nblacklist snd_hda_codec\nblacklist snd_hda_core\nblacklist radeon\nblacklist amdgpu\nblacklist i915\noptions vfio_iommu_type1 allow_unsafe_interrupts=1\n# \u5982\u679c\u6709\u91cd\u590d\u9879,\u8bb0\u5f97\u5220\u9664,\u89e3\u91ca\uff1a\u5c4f\u853d\u4e09\u5927\u663e\u5361\u9a71\u52a8\uff0c\u5c4f\u853dhdmi\u58f0\u97f3\u9a71\u52a8\uff1boptions<\/pre>\n\n\n\n<p><strong>\u67e5\u770b\u76f4\u901a\u8bbe\u5907&nbsp;<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#\u6267\u884c lspci -nn \u53ef\u547d\u4ee4\u67e5\u770b\u9700\u8981\u76f4\u901a\u8bbe\u5907<\/pre>\n\n\n\n<p><strong>\u66f4\u65b0\u6a21\u5757\u5e76\u91cd\u65b0\u542f\u52a8\u4e3b\u673a\u4ee5\u5e94\u7528\u66f4\u6539<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">update-initramfs -u -k all<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u786c\u76d8\u76f4\u901a<\/p>\n\n\n\n<p>find \/dev\/disk\/by-id\/ -type l|xargs -I{} ls -l {}|grep -v -E &#8216;[0-9]$&#8217; |sort -k11|cut -d&#8217; &#8216; -f9,10,11,12<\/p>\n\n\n\n<p>\u7136\u540e\u5b83\u4f1a\u663e\u793a\u60a8\u60f3\u8981\u7684\u78c1\u76d8\u7684\u5b8c\u6574\u8def\u5f84\u3002<br>\u590d\u5236\u8def\u5f84\u3002<\/p>\n\n\n\n<p>qm set {vmid} -{disk-type}{number} \/dev\/disk\/by-id\/{disk-serial}<br>\u5bf9\u4e8e Windows \u548c Linux\uff0c\u786c\u76d8\u7c7b\u578b\u63a8\u8350\uff1b SCSI\u3002<br>\u5bf9\u4e8e macOS\uff0c\u786c\u76d8\u7c7b\u578b\u63a8\u8350\uff1b virtio\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u5982\u679c\u60a8\u60f3\u5728\u6dfb\u52a0\u78c1\u76d8\u540e\u5c06\u5176\u4ece\u865a\u62df\u673a\u4e2d\u5220\u9664\uff0c\u8bf7\u5728 Shell \u4e2d\u952e\u5165\u4ee5\u4e0b\u5185\u5bb9\u3002<br>{\u78c1\u76d8\u7c7b\u578b}{\u7f16\u53f7} \u4f8b\u5982 scsi1<br>qm unlink {vmid} &#8211;idlist {disk-type}{number}<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>ls -l \/dev\/disk\/by-id\/<\/p>\n\n\n\n<p>ls -l&nbsp;<\/p>\n\n\n\n<p>qm set 101 -sata1 \/dev\/disk\/by-id\/ata-ST2000DM005-2U9102_WFM3S264<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f00\u542fiommu\u76f4\u901a nano \/etc\/modprobe.d\/kvm.conf options kvm ign&hellip; <a class=\"more-link\" href=\"https:\/\/cliyr.cn\/?p=383\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">PVE\u98de\u725b\u786c\u76d8\u76f4\u901a<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/cliyr.cn\/index.php?rest_route=\/wp\/v2\/posts\/383"}],"collection":[{"href":"https:\/\/cliyr.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cliyr.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cliyr.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cliyr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383"}],"version-history":[{"count":2,"href":"https:\/\/cliyr.cn\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":392,"href":"https:\/\/cliyr.cn\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions\/392"}],"wp:attachment":[{"href":"https:\/\/cliyr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cliyr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cliyr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}