开启左侧

虚拟机开启PCIE硬件直通(英特尔)

发表于:2025-1-21 18:48:03 教程 7497
什么是硬件直通(Passthrough) VT-d 、DirectPath I/O,通过 DirectPath I/O,虚拟机可以使用 I/O 内存管理单元访问平台上的物理 PCI 功能,就是俗称的虚拟化直通,简单理解就是允许宿主机将某些硬件资源的管辖权直接移交给虚拟机,虚拟机会以直通独占的方式使用硬件,宿主机将不能再使用此硬件,利用效率几乎等同于将硬件插到了虚拟机的主板扩展槽里一样,最实用的目的是避免了虚拟化平台自身软件层转换带来的效能下降。

在开启IOMMU功能实现硬件直通之前,我们要确认CPU是否支持VT-D/VT-X技术;开启直通的必要条件 CPU支持VT-D/VT-X,同时主板要开启VT-D/VT-X支持。4f18987e23ed74dd63b94e7fbfbc3cec.png

启用IOMMU功能(以下仅适用英特尔,AMD操作类似具体自查)

通过修改飞牛的GRUB文件开启(需要先在主板开启VT-D/VT-X)

1,ssh中输入命令:

nano /etc/default/grub

2,在里面找到 GRUB_CMDLINE_LINUX_DEFAULT=

3,在 GRUB_CMDLINE_LINUX_DEFAULT= quiet的后面添加 intel_iommu=on

例如:GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"原本后面还有其他的在on后面加个空格就行不要做删减。编辑完成后,使用快捷键 Ctrl + O 回车保存文件,Ctrl + X 退出编辑器。

4,使用命令 update-grub 保存更改并更新grub

5、更新完成后,使用命令 reboot 重启

d57f9969d38449678360c88bd3892324.png

收藏
送赞 20
分享

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

发表回复

评论列表(55)

先输入 sudo -i
2025-1-21 22:11:05 5 回复
很好,要的就是这个~~
2025-1-21 19:53:30 回复
等这个好久了,一直不能直通
2025-1-21 20:04:05 回复
请问我的是这个GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.force_probe=xxxx",怎么加呢?GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on i915.force_probe=xxxx",这样子吗
2025-1-21 21:03:07 回复
没仔细看怪我。。。。  详情 回复
2025-1-21 21:04
没仔细看怪我。。。。
2025-1-21 21:04:18 回复
我和你一样的情况,你是怎么添加的哈,成功了么  详情 回复
2025-1-23 13:37
你弄好了吗,我怎么改了也不行  详情 回复
2025-1-22 20:21
畅网N100小主机先锋v2版修改有用   GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on i915.force_probe=7d55"   修改内容如此
2025-1-21 21:43:07 回复
感谢,终于成功了,我的N305,折腾一上午。  详情 回复
2025-1-24 17:10
保存的时候提示拒绝写入“ [ Error writing /etc/default/grub: Permission denied ]  。这是啥情况
2025-1-21 21:59:11 回复
先输入 sudo -i  详情 回复
2025-1-21 22:11
就是等这个!!
2025-1-21 22:22:01 回复
谢谢分享开启的方法
2025-1-21 23:04:11 回复
root@testFos:~# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.6.38-trim
Found initrd image: /boot/initrd.img-6.6.38-trim
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
更新grub的时候提示这个,不会了
2025-1-21 23:24:01 回复
GRUB_DISABLE_OS_PROBER=false 这一项默认是被注释的,需要去掉注释就可以完成update-grub 但是奇怪的是我更新后还是不能开启IOMMU  详情 回复
2025-1-21 23:41
直通完,设备管理器显示核显为uhd一个感叹号,实际未启用,驱动装了
2025-1-21 23:29:28 2 回复
GRUB_DISABLE_OS_PROBER=false
这一项默认是被注释的,需要去掉注释就可以完成update-grub
但是奇怪的是我更新后还是不能开启IOMMU
2025-1-21 23:41:11 回复
同样的情形,GRUB_DISABLE_OS_PROBER=false去掉注释不行,删除本句不行。确认bios设置正常,cpu支持VT-d,操作多次依旧,等更新了。另一台笔记本做的nas一次成功。  详情 回复
2025-2-9 21:49
我也是,你解决了吗  详情 回复
2025-1-24 18:21
J3160的板子,更新前是正常的,更新后就灰了,命令执行也正常,但还是开启不了,准备重新装一下虚拟机
2025-1-22 00:00:12 回复
j3160开启不了IOMMU吧?j3160不支持Intel vt-d技术。  详情 回复
2025-2-3 09:03
感谢分享
2025-1-22 01:23:19 回复
打开了IOMMU,没把显卡直通给虚拟机,影视不能硬件解码。有没有办法既能虚拟机能用核显,影视又能硬件解码?
2025-1-22 09:55:43 2 回复
现阶段应该还不行,暂时还不支持vGPU的样子  详情 回复
2025-1-22 20:44
感谢感谢
2025-1-22 15:05:19 回复
lubover 发表于 2025-1-21 21:04
没仔细看怪我。。。。

你弄好了吗,我怎么改了也不行
2025-1-22 20:21:02 回复
成了,GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.force_probe=7d55 intel_iommu=on iommu=pt" 这样  详情 回复
2025-1-23 15:32
现阶段应该还不行,暂时还不支持vGPU的样子
2025-1-22 20:44:14 回复
IOMMU分组没法拆分,同一个通道的硬件只能全部直通
2025-1-22 22:49:20 回复
解决了么  详情 回复
2025-2-28 13:31
遇到同一问题  详情 回复
2025-1-23 03:34
遇到同一问题
2025-1-23 03:34:33 回复
lubover 发表于 2025-1-21 21:04
没仔细看怪我。。。。

我和你一样的情况,你是怎么添加的哈,成功了么
2025-1-23 13:37:57 回复
成了,GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.force_probe=7d55 intel_iommu=on iommu=pt" 这样  详情 回复
2025-1-23 15:32
积木城池 发表于 2025-1-23 13:37
我和你一样的情况,你是怎么添加的哈,成功了么

成了,GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.force_probe=7d55 intel_iommu=on iommu=pt"        这样
2025-1-23 15:32:20 回复
成了,GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.force_probe=7d55 intel_iommu=on iommu=pt"        这样
2025-1-23 15:32:51 回复
你确定成了,开了是开了,但windows核显还是有感叹号显示,代码43  详情 回复
2025-1-23 15:53
你确定成了,开了是开了,但windows核显还是有感叹号显示,代码43
2025-1-23 15:53:52 回复
核显还得等SR-IOV  详情 回复
2025-1-24 11:37
知道飞牛可以虚拟机就黑裙转过来了,结果还有这个问题等着,研究了半天终于找到教程搞定了,感谢楼主
2025-1-23 16:16:24 回复
主板开启了虚拟,按照这个修改重启后还是没开启
2025-1-23 17:14:15 回复
/usr/sbin/grub-mkconfig: 9: /etc/default/grub: i915.force_probe=7d55: not found   这啥情况
2025-1-23 21:30:24 回复
/usr/sbin/grub-mkconfig: 1: /etc/default/grub: i915.force_probe=7d55: not found  详情 回复
2025-2-4 19:48
谢谢 刚好用上
2025-1-24 08:39:15 回复
夜想曲 发表于 2025-1-23 15:53
你确定成了,开了是开了,但windows核显还是有感叹号显示,代码43

核显还得等SR-IOV
2025-1-24 11:37:28 回复
论坛有另一贴讲了怎么开sr-iov了,不过我不知道核显内核怎么编译()  详情 回复
2025-1-24 11:51
论坛有另一贴讲了怎么开sr-iov了,不过我不知道核显内核怎么编译()
2025-1-24 11:51:01 回复
感谢,终于成功了,我的N305,折腾一上午。
2025-1-24 17:10:29 回复
我也是,你解决了吗
2025-1-24 18:21:05 回复
j3160开启不了IOMMU吧?j3160不支持Intel vt-d技术。
2025-2-3 09:03:16 回复
难怪 ,我折腾了两天。  详情 回复
2025-2-21 17:21
/usr/sbin/grub-mkconfig: 1: /etc/default/grub: i915.force_probe=7d55: not found
2025-2-4 19:48:49 回复
小白问一下用什么编辑器啊????
2025-2-6 15:45:32 回复
vim,vi,nano  详情 回复
2025-2-6 19:39
vim,vi,nano
2025-2-6 19:39:52 回复
谢谢你了!!!!!  详情 回复
2025-2-6 21:30
谢谢你了!!!!!
2025-2-6 21:30:31 回复
IOMMU开启成功,感谢哟
2025-2-8 08:27:49 回复
小白一枚,大神能否分享一下具体是怎么操作的,谢谢!!  详情 回复
2025-2-8 08:46
小白一枚,大神能否分享一下具体是怎么操作的,谢谢!!
2025-2-8 08:46:02 回复
本人用dellt台式机作nas主机,已经修改了BIOS,进入飞牛终端后获得root后输入nano /etc/default/grub显示no such file or directory,请指教
2025-2-8 13:15:41 回复
风语者 发表于 2025-1-21 23:41
GRUB_DISABLE_OS_PROBER=false
这一项默认是被注释的,需要去掉注释就可以完成update-grub
但是奇怪的是我 ...

同样的情形,GRUB_DISABLE_OS_PROBER=false去掉注释不行,删除本句不行。确认bios设置正常,cpu支持VT-d,操作多次依旧,等更新了。另一台笔记本做的nas一次成功。
2025-2-9 21:49:47 回复
查了一下我的电脑硬件不支持😫
即使通过 GRUB 启用了相关参数,如果处理器本身不支持 VT-d,系统也无法利用该功能。因此,对于 i5-3230M 这种不支持 VT-d 的处理器,无法通过软件配置实现 VT-d 功能
2025-2-15 09:16:19 回复
FNOS不识别我的nvdia mx330显卡,正好直通给win11虚拟机,美滋滋。提醒,命令执行不动的话前面加上sudo
2025-2-19 20:27:33 回复
开不了机
time="2025-02-21T09:35:15+08:00" level=error msg="Failed to execute monitor **" error="virError(Code=38, Domain=7, Message='Cannot write data: Broken pipe')"
virtual-machine/vmsrv/core/**s.(*Monitor**).Run(0x0?)
        /app/core/**s/monitor.go:17 +0x74
github.com/robfig/cron/v3.(*Cron).start**.func1()
        /go/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:312 +0x55
created by github.com/robfig/cron/v3.(*Cron).start** in goroutine 12
        /go/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:310 +0x90
time="2025-02-21T09:35:16+08:00" level=fatal msg="Failed to connect to qemu:///system: virError(Code=38, Domain=7, Message='Cannot write data: Broken pipe')"
time="2025-02-21T09:43:44+08:00" level=error msg="Failed to execute monitor **" error="virError(Code=38, Domain=7, Message='Cannot write data: Broken pipe')"
virtual-machine/vmsrv/core/**s.(*Monitor**).Run(0x0?)
        /app/core/**s/monitor.go:17 +0x74
github.com/robfig/cron/v3.(*Cron).start**.func1()
        /go/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:312 +0x55
created by github.com/robfig/cron/v3.(*Cron).start** in goroutine 51
        /go/pkg/mod/github.com/robfig/cron/v3@v3.0.1/cron.go:310 +0x90
time="2025-02-21T09:43:45+08:00" level=fatal msg="Failed to connect to qemu:///system: virError(Code=38, Domain=7, Message='Cannot write data: Broken pipe')"
time="2025-02-21T09:47:10+08:00" level=error msg="1740102430 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T01:47:08.027116Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744056970975260 bytes\", Level:2}"
time="2025-02-21T09:48:08+08:00" level=error msg="1740102488 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T01:48:05.559066Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744060953575964 bytes\", Level:2}"
time="2025-02-21T09:48:34+08:00" level=error msg="1740102514 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T01:48:31.339177Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744056948599324 bytes\", Level:2}"
time="2025-02-21T09:52:05+08:00" level=error msg="1740102725 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T01:52:02.252272Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744064197751324 bytes\", Level:2}"
time="2025-02-21T09:56:25+08:00" level=error msg="1740102985 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T01:56:23.380225Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744071298037276 bytes\", Level:2}"
time="2025-02-21T09:56:39+08:00" level=error msg="1740102999 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T01:56:36.988136Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744056948641308 bytes\", Level:2}"
time="2025-02-21T10:02:50+08:00" level=error msg="1740103370 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T02:02:48.314444Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744066650608156 bytes\", Level:2}"
time="2025-02-21T10:04:41+08:00" level=error msg="1740103481 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T02:04:39.749254Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744060449182748 bytes\", Level:2}"
time="2025-02-21T10:05:04+08:00" level=error msg="1740103504 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T02:05:03.047170Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744061311834652 bytes\", Level:2}"
time="2025-02-21T10:05:26+08:00" level=error msg="1740103526 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T02:05:25.088110Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744060451618844 bytes\", Level:2}"
time="2025-02-21T10:08:52+08:00" level=error msg="1740103732 - Libvirt Err: libvirt.Error{Code:1, Domain:10, Message:\"internal error: qemu unexpectedly closed the monitor: 2025-02-21T02:08:50.346939Z qemu-system-x86_64: GLib: ../../../glib/gmem.c:207: failed to allocate 18446744060937944092 bytes\", Level:2}"
2025-2-21 10:46:15 回复
i5-4210u    bios里开启了虚拟化的  按照步骤来还是打不开IOMMU
2025-2-21 14:01:13 回复
鸿雁x 发表于 2025-2-3 09:03
j3160开启不了IOMMU吧?j3160不支持Intel vt-d技术。

难怪 ,我折腾了两天。
2025-2-21 17:21:13 回复
保存提示这个 /etc/default/grub: ou: not found也没输入错误啊
2025-2-22 14:24:26 回复
用root权限 sudo -i  详情 回复
2025-2-22 15:27
用root权限 sudo -i
2025-2-22 15:27:49 回复
j3455 原来开通了iommu,一升及系统,又关闭IOMMU了。实在头疼。。到底咋弄呢。官方也不出个设置界面
2025-2-27 21:44:31 回复
12下一页