我正在尝试让 GPU 直通在虚拟机上运行。我一直在关注这个视频https://www.youtube.com/watch?v=6FI31QDtyy4。我所做的和他在视频中所做的区别在于 mkinitcpio 配置中的模块,我使用了“MODULES=(vfio_pci vfio vfio_iommu_type1 vfio_virqfd)”因为视频有点过时了。
所以我做的是
- 在 grub params 中添加 intel_iommu=on
- 检查我的系统是否支持 IOMMU,我运行了“dmesg | grep -e DMAR -e IOMMU”
- 将“options vfio-pci ids=10de:10f0,10de:1b81”添加到 vfio.conf
- 如上所述修改 mkinitcpio.conf
- 运行‘mkinitcpio -p linux’
- 修改 qemu.conf(可能不相关)
- 运行“systemctl enable --now libvirtd”和“systemctl enable virtlogd.socket”
- 重新启动并返回 Windows 10(非双启动。我正在通过 USB 记忆棒(非 LIVE USB)运行 arch)(尝试添加 vm 但失败了,因为我没有执行 ntfs-3g 操作)
- 从 Windows 10 回来并在 fstab 中添加“UUID=061A04D11A04C023 /media/Data/ntfs-3g defaults 0 0”
- 在 /etc/default/grub 中将 'GRUB_CMDLINE_LINUX_DEFAULT="quiet"' 更改为 'GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"'
- 重新启动并停留在“正在加载版本 240(当我从 params 中删除 intel_iommu=on 时,它启动正常)
第一次启动时 iommu 工作正常,我使用 GPU 作为输出。上次启动时 GPU 不工作(无信号),我尝试使用 iGPU。此外,我还查看了 Arch 官方 wiki 中有关 PCI 直通的内容,步骤非常相似
/etc/mkinitcpio.conf:
# vim:set ft=sh
# MODULES
# The following modules are loaded before any boot hooks are
# run. Advanced users may wish to specify all system modules
# in this array. For instance:
# MODULES=(piix ide_disk reiserfs)
MODULES=(vfio_pci vfio vfio_iommu_type1 vfio_virqfd)
# BINARIES
# This setting includes any additional binaries a given user may
# wish into the CPIO image. This is run last, so it may be used to
# override the actual binaries included by a given hook
# BINARIES are dependency parsed, so you may safely ignore libraries
BINARIES=()
# FILES
# This setting is similar to BINARIES above, however, files are added
# as-is and are not parsed in any way. This is useful for config files.
FILES=()
# HOOKS
# This is the most important setting in this file. The HOOKS control the
# modules and scripts added to the image, and what happens at boot time.
# Order is important, and it is recommended that you do not change the
# order in which HOOKS are added. Run 'mkinitcpio -H <hook name>' for
# help on a given hook.
# 'base' is _required_ unless you know precisely what you are doing.
# 'udev' is _required_ in order to automatically load modules
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
# Examples:
## This setup specifies all modules in the MODULES setting above.
## No raid, lvm2, or encrypted root is needed.
# HOOKS=(base)
#
## This setup will autodetect all modules for your system and should
## work as a sane default
# HOOKS=(base udev autodetect block filesystems)
#
## This setup will generate a 'full' image which supports most systems.
## No autodetection is done.
# HOOKS=(base udev block filesystems)
#
## This setup assembles a pata mdadm array with an encrypted root FS.
## Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
# HOOKS=(base udev block mdadm encrypt filesystems)
#
## This setup loads an lvm2 volume group on a usb device.
# HOOKS=(base udev block lvm2 filesystems)
#
## NOTE: If you have /usr on a separate partition, you MUST include the
# usr, fsck and shutdown hooks.
HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)
# COMPRESSION
# Use this to compress the initramfs image. By default, gzip compression
# is used. Use 'cat' to create an uncompressed image.
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
#COMPRESSION="xz"
#COMPRESSION="lzop"
#COMPRESSION="lz4"
# COMPRESSION_OPTIONS
# Additional options for the compressor
#COMPRESSION_OPTIONS=()
/etc/modprobe.d/vfio.conf:
options vfio-pci ids=10de:10f0,10de:1b81
内核版本:4.20.10-arch1-1-ARCH
硬件信息 (lshw):
cube-arch
description: Desktop Computer
product: B360M-HD3 (Default string)
vendor: Gigabyte Technology Co., Ltd.
version: Default string
serial: Default string
width: 4294967295 bits
capabilities: smbios-3.1 dmi-3.1 smp vsyscall32
configuration: boot=normal chassis=desktop family=Default string sku=Default string uuid=E002D503-5E04-7905-ED06-310700080009
*-core
description: Motherboard
product: B360M HD3
vendor: Gigabyte Technology Co., Ltd.
physical id: 0
version: x.x
serial: Default string
slot: Default string
*-firmware
description: BIOS
vendor: American Megatrends Inc.
physical id: 0
version: F4
date: 04/19/2018
size: 64KiB
capacity: 15MiB
capabilities: pci upgrade shadowing cdboot bootselect socketedrom edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int14serial int17printer acpi usb biosbootspecification uefi
*-memory
description: System Memory
physical id: 3a
slot: System board or motherboard
size: 16GiB
*-bank:0
description: DIMM DDR4 Synchronous 2133 MHz (0.5 ns)
product: F4-3000C16-8GISB
vendor: Fujitsu
physical id: 0
serial: 00000000
slot: ChannelA-DIMM0
size: 8GiB
width: 64 bits
clock: 2133MHz (0.5ns)
*-bank:1
description: [empty]
physical id: 1
slot: ChannelA-DIMM1
*-bank:2
description: DIMM DDR4 Synchronous 2133 MHz (0.5 ns)
product: F4-3000C16-8GISB
vendor: Fujitsu
physical id: 2
serial: 00000000
slot: ChannelB-DIMM0```
答案1
解决了
我太笨了,我把显示器插到 GPU 上,插到 iGPU 上后它就工作了。确保在 BIOS 中将其设为主输出