PCI 直通後更改 Xorg/GDM 的預設 GPU 裝置?

PCI 直通後更改 Xorg/GDM 的預設 GPU 裝置?

Intel Corporation HD Graphics 510設備應用於 Ubuntu 主機系統。

NVIDIA Corporation GP107設備已保留供 KVM 使用。

Ubuntu主機系統無法正確Intel Corporation HD Graphics 510連接X伺服器。我們可以解決它嗎?

sudo systemctl start gdm指令會導致TTY不斷閃爍,難以使用。

sudo cat /etc/default/grub | sudo cat /etc/default/grub | grep 指令

GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity nouveau.runpm=0"
GRUB_CMDLINE_LINUX="rd.modules-load=vfio-pci intel_iommu=on"

貓 /etc/modprobe.d/local.conf

options vfio-pci ids=10de:1c81,10de:0fb9
options vfio-pci disable_vga=1

sudo 更新 grub

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-32-generic
Found initrd image: /boot/initrd.img-4.15.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-30-generic
Found initrd image: /boot/initrd.img-4.15.0-30-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done

sudo update-initramfs -u

update-initramfs: Generating /boot/initrd.img-4.15.0-32-generic

systemctl 重新啟動

貓 ~/.local/share/xorg/Xorg.0.log

[   876.205] (II) systemd-logind: took control of session /org/freedesktop/login1/session/_3253
[   876.206] (II) xfree86: Adding drm device (/dev/dri/card0)
[   876.208] (II) systemd-logind: got fd for /dev/dri/card0 226:0 fd 11 paused 0
[   876.214] (--) PCI: (0:0:2:0) 8086:1902:1462:7995 rev 6, Mem @ 0xdd000000/16777216, 0xb0000000/268435456, I/O @ 0x0000f000/64
[   876.214] (--) PCI:*(0:1:0:0) 10de:1c81:1462:8c97 rev 161, Mem @ 0xde000000/16777216, 0xc0000000/268435456, 0xd0000000/33554432, I/O @ 0x0000e000/128, BIOS @ 0x????????/131072
[   876.214] (II) LoadModule: "glx"
[   876.214] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so

lspci-tvnnk

-[0000:00]-+-00.0  Intel Corporation Skylake Host Bridge/DRAM Registers [8086:190f]
        +-01.0-[01]--+-00.0  NVIDIA Corporation GP107 [GeForce GTX 1050] [10de:1c81]
        |            \-00.1  NVIDIA Corporation GP107GL High Definition Audio Controller [10de:0fb9]
        +-02.0  Intel Corporation HD Graphics 510 [8086:1902]
        +-08.0  Intel Corporation Skylake Gaussian Mixture Model [8086:1911]
        +-14.0  Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller [8086:a12f]
        +-14.2  Intel Corporation Sunrise Point-H Thermal subsystem [8086:a131]
        +-16.0  Intel Corporation Sunrise Point-H CSME HECI #1 [8086:a13a]
        +-17.0  Intel Corporation Sunrise Point-H SATA controller [AHCI mode] [8086:a102]
        +-1d.0-[02]----00.0  Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168]
        +-1f.0  Intel Corporation Sunrise Point-H LPC Controller [8086:a143]
        +-1f.2  Intel Corporation Sunrise Point-H PMC [8086:a121]
        +-1f.3  Intel Corporation Sunrise Point-H HD Audio [8086:a170]
        \-1f.4  Intel Corporation Sunrise Point-H SMBus [8086:a123]

lspci-nnks 01:00

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP107 [GeForce GTX 1050] [10de:1c81] (rev a1)
    Subsystem: Micro-Star International Co., Ltd. [MSI] GP107 [GeForce GTX 1050] [1462:8c97]
    Kernel driver in use: vfio-pci
    Kernel modules: nvidiafb, nouveau
01:00.1 Audio device [0403]: NVIDIA Corporation GP107GL High Definition Audio Controller [10de:0fb9] (rev a1)
    Subsystem: Micro-Star International Co., Ltd. [MSI] GP107GL High Definition Audio Controller [1462:8c97]
    Kernel driver in use: vfio-pci
    Kernel modules: snd_hda_intel

lspci-nnks 00:02

00:02.0 Display controller [0380]: Intel Corporation HD Graphics 510 [8086:1902] (rev 06)
    Subsystem: Micro-Star International Co., Ltd. [MSI] HD Graphics 510 [1462:7995]
    Kernel driver in use: i915
    Kernel modules: i915

gpu-manager.log:

log_file: /var/log/gpu-manager.log
last_boot_file: /var/lib/ubuntu-drivers-common/last_gfx_boot
new_boot_file: /var/lib/ubuntu-drivers-common/last_gfx_boot
can't access /run/u-d-c-nvidia-was-loaded file
can't access /opt/amdgpu-pro/bin/amdgpu-pro-px
Looking for nvidia modules in /lib/modules/4.15.0-32-generic/updates/dkms
Looking for amdgpu modules in /lib/modules/4.15.0-32-generic/updates/dkms
Is nvidia loaded? no
Was nvidia unloaded? no
Is nvidia blacklisted? no
Is intel loaded? yes
Is radeon loaded? no
Is radeon blacklisted? no
Is amdgpu loaded? no
Is amdgpu blacklisted? no
Is amdgpu versioned? no
Is amdgpu pro stack? no
Is nouveau loaded? no
Is nouveau blacklisted? yes
Is nvidia kernel module available? no
Is amdgpu kernel module available? no
Vendor/Device Id: 8086:1902
BusID "PCI:0@0:2:0"
Is boot vga? no
Vendor/Device Id: 10de:1c81
BusID "PCI:1@0:0:0"
Is boot vga? yes
Skipping "/dev/dri/card0", driven by "i915"
Skipping "/dev/dri/card0", driven by "i915"
Skipping "/dev/dri/card0", driven by "i915"
Found "/dev/dri/card0", driven by "i915"
output 0:
        card0-HDMI-A-1
Number of connected outputs for /dev/dri/card0: 1
Does it require offloading? yes
last cards number = 2
Has amd? no
Has intel? yes
Has nvidia? yes
How many cards? 2
Has the system changed? No
Unsupported discrete card vendor: 8086
Nothing to do

Xorg.0.log:

$ cat ~/.local/share/xorg/Xorg.0.log
[  2684.239]
X.Org X Server 1.19.6
Release Date: 2017-12-20
[  2684.244] X Protocol Version 11, Revision 0
[  2684.246] Build Operating System: Linux 4.4.0-119-generic x86_64 Ubuntu
[  2684.247] Current Operating System: Linux ab350n2 4.15.0-32-generic #35-Ubuntu SMP Fri Aug 10 17:58:07 UTC 2018 x86_64
[  2684.247] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-32-generic root=UUID=87ad8dee-9975-11e8-a30b-309c230abb92 ro rd.modules-load=vfio-pci intel_iommu=on maybe-ubiquity
[  2684.251] Build Date: 13 April 2018  08:07:36PM
[  2684.253] xorg-server 2:1.19.6-1ubuntu4 (For technical support please see http://www.ubuntu.com/support)
[  2684.254] Current version of pixman: 0.34.0
[  2684.258]    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
[  2684.258] Markers: (--) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[  2684.265] (==) Log file: "/home/$USER/.local/share/xorg/Xorg.0.log", Time: Tue Aug 21 11:35:44 2018
[  2684.267] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[  2684.267] (==) No Layout section.  Using the first Screen section.
[  2684.267] (==) No screen section available. Using defaults.
[  2684.267] (**) |-->Screen "Default Screen Section" (0)
[  2684.267] (**) |   |-->Monitor "<default monitor>"
[  2684.267] (==) No monitor specified for screen "Default Screen Section".
    Using a default monitor configuration.
[  2684.267] (==) Automatically adding devices
[  2684.267] (==) Automatically enabling devices
[  2684.267] (==) Automatically adding GPU devices
[  2684.267] (==) Automatically binding GPU devices
[  2684.267] (==) Max clients allowed: 256, resource mask: 0x1fffff
[  2684.267] (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (==) FontPath set to:
    /usr/share/fonts/X11/misc,
    /usr/share/fonts/X11/Type1,
    built-ins
[  2684.267] (==) ModulePath set to "/usr/lib/xorg/modules"
[  2684.267] (II) The server relies on udev to provide the list of input devices.
    If no devices become available, reconfigure udev or disable AutoAddDevices.
[  2684.267] (II) Loader magic: 0x564f402c8020
[  2684.267] (II) Module ABI versions:
[  2684.267]    X.Org ANSI C Emulation: 0.4
[  2684.267]    X.Org Video Driver: 23.0
[  2684.267]    X.Org XInput driver : 24.1
[  2684.267]    X.Org Server Extension : 10.0
[  2684.268] (++) using VT number 5

[  2684.269] (II) systemd-logind: took control of session /org/freedesktop/login1/session/_3253
[  2684.270] (II) xfree86: Adding drm device (/dev/dri/card0)
[  2684.270] (II) systemd-logind: got fd for /dev/dri/card0 226:0 fd 11 paused 0
[  2684.271] (--) PCI: (0:0:2:0) 8086:1902:1462:7995 rev 6, Mem @ 0xdd000000/16777216, 0xb0000000/268435456, I/O @ 0x0000f000/64
[  2684.271] (--) PCI:*(0:1:0:0) 10de:1c81:1462:8c97 rev 161, Mem @ 0xde000000/16777216, 0xc0000000/268435456, 0xd0000000/33554432, I/O @ 0x0000e000/128, BIOS @ 0x????????/131072
[  2684.271] (II) LoadModule: "glx"
[  2684.272] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so
[  2684.272] (II) Module glx: vendor="X.Org Foundation"
[  2684.272]    compiled for 1.19.6, module version = 1.0.0
[  2684.272]    ABI class: X.Org Server Extension, version 10.0
[  2684.272] (==) Matched nouveau as autoconfigured driver 0
[  2684.272] (==) Matched modesetting as autoconfigured driver 1
[  2684.272] (==) Matched fbdev as autoconfigured driver 2
[  2684.272] (==) Matched vesa as autoconfigured driver 3
[  2684.272] (==) Assigned the driver to the xf86ConfigLayout
[  2684.272] (II) LoadModule: "nouveau"
[  2684.272] (II) Loading /usr/lib/xorg/modules/drivers/nouveau_drv.so
[  2684.272] (II) Module nouveau: vendor="X.Org Foundation"
[  2684.272]    compiled for 1.19.3, module version = 1.0.15
[  2684.272]    Module class: X.Org Video Driver
[  2684.272]    ABI class: X.Org Video Driver, version 23.0
[  2684.272] (II) LoadModule: "modesetting"
[  2684.272] (II) Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so
[  2684.272] (II) Module modesetting: vendor="X.Org Foundation"
[  2684.272]    compiled for 1.19.6, module version = 1.19.6
[  2684.272]    Module class: X.Org Video Driver
[  2684.272]    ABI class: X.Org Video Driver, version 23.0
[  2684.272] (II) LoadModule: "fbdev"
[  2684.272] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
[  2684.272] (II) Module fbdev: vendor="X.Org Foundation"
[  2684.272]    compiled for 1.19.3, module version = 0.4.4
[  2684.272]    Module class: X.Org Video Driver
[  2684.272]    ABI class: X.Org Video Driver, version 23.0
[  2684.272] (II) LoadModule: "vesa"
[  2684.272] (II) Loading /usr/lib/xorg/modules/drivers/vesa_drv.so
[  2684.273] (II) Module vesa: vendor="X.Org Foundation"
[  2684.273]    compiled for 1.19.3, module version = 2.3.4
[  2684.273]    Module class: X.Org Video Driver
[  2684.273]    ABI class: X.Org Video Driver, version 23.0
[  2684.273] (II) NOUVEAU driver Date:   Fri Apr 21 14:41:17 2017 -0400
[  2684.273] (II) NOUVEAU driver for NVIDIA chipset families :
[  2684.273]    RIVA TNT        (NV04)
[  2684.273]    RIVA TNT2       (NV05)
[  2684.273]    GeForce 256     (NV10)
[  2684.273]    GeForce 2       (NV11, NV15)
[  2684.273]    GeForce 4MX     (NV17, NV18)
[  2684.273]    GeForce 3       (NV20)
[  2684.273]    GeForce 4Ti     (NV25, NV28)
[  2684.273]    GeForce FX      (NV3x)
[  2684.273]    GeForce 6       (NV4x)
[  2684.273]    GeForce 7       (G7x)
[  2684.273]    GeForce 8       (G8x)
[  2684.273]    GeForce GTX 200 (NVA0)
[  2684.273]    GeForce GTX 400 (NVC0)
[  2684.273] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[  2684.273] (II) FBDEV: driver for framebuffer: fbdev
[  2684.273] (II) VESA: driver for VESA chipsets: vesa
[  2684.273] xf86EnableIOPorts: failed to set IOPL for I/O (Operation not permitted)
[  2684.391] (EE) [drm] Failed to open DRM device for pci:0000:01:00.0: -19
[  2684.391] (WW) Falling back to old probe method for modesetting
[  2684.391] (II) modeset(1): using default device
[  2684.391] (II) Loading sub module "fbdevhw"
[  2684.391] (II) LoadModule: "fbdevhw"
[  2684.391] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
[  2684.391] (II) Module fbdevhw: vendor="X.Org Foundation"
[  2684.391]    compiled for 1.19.6, module version = 0.0.2
[  2684.392]    ABI class: X.Org Video Driver, version 23.0
[  2684.392] (EE) open /dev/fb0: Permission denied
[  2684.392] (WW) Falling back to old probe method for fbdev
[  2684.392] (II) Loading sub module "fbdevhw"
[  2684.392] (II) LoadModule: "fbdevhw"
[  2684.392] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
[  2684.392] (II) Module fbdevhw: vendor="X.Org Foundation"
[  2684.392]    compiled for 1.19.6, module version = 0.0.2
[  2684.392]    ABI class: X.Org Video Driver, version 23.0
[  2684.392] (EE) open /dev/fb0: Permission denied
[  2684.392] vesa: Ignoring device with a bound kernel driver
[  2684.392] (WW) Falling back to old probe method for vesa
[  2684.392] (II) modeset(G0): using drv /dev/dri/card0
[  2684.392] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
[  2684.392] (EE) Screen 0 deleted because of no matching config section.
[  2684.392] (II) UnloadModule: "modesetting"
[  2684.392] (EE) Screen 1 deleted because of no matching config section.
[  2684.392] (II) UnloadModule: "fbdev"
[  2684.392] (II) UnloadSubModule: "fbdevhw"
[  2684.392] (EE) Screen 1 deleted because of no matching config section.
[  2684.392] (II) UnloadModule: "vesa"
[  2684.392] (EE)
Fatal server error:
[  2684.392] (EE) Cannot run in framebuffer mode. Please specify busIDs        for all framebuffer devices
[  2684.392] (EE)
[  2684.392] (EE)
Please consult the The X.Org Foundation support
    at http://wiki.x.org
for help.
[  2684.392] (EE) Please also check the log file at "/home/$USER/.local/share/xorg/Xorg.0.log" for additional information.
[  2684.392] (EE)
[  2684.423] (EE) Server terminated with error (1). Closing log file.

答案1

看來 Xorg 無論如何都在嘗試使用 NVIDIA 卡。你試過了嗎指定 Xorg 應使用哪個 GPU

啟用 vfio_pci 後 X 無法啟動

這與主機 GPU 被偵測為輔助 GPU 相關,這會導致 X 在嘗試為來賓 GPU 載入驅動程式時失敗/崩潰。為了避免這種情況,需要一個指定主機 GPU 匯流排 ID 的 Xorg 設定檔。正確的BusID可以從lspci或Xorg日誌取得。來源 →

/etc/X11/xorg.conf.d/10-intel.conf

Section "Device"
        Identifier "Intel GPU"
        Driver "modesetting"
        BusID  "PCI:0:2:0"
EndSection

如果xorg.conf.d尚不存在,只需創建它。

此後,Xorg 不應再嘗試使用 NVIDIA 顯示卡。 Arch Wiki 頁面列出了隨著您的進一步進展您可能會發現有趣的其他問題。

答案2

在桌上型電腦中安裝第二個 NVIDIA GPU 後,我遇到了相關問題。嘗試啟動時,日誌會顯示 gdm(Gnome Display Manager 3)已啟動,但我只看到左上角有一個閃爍的遊標。

正如 @Daniel B 在接受的答案中提到的,修復與 Xorg 配置文件有關。我能夠使用 NVIDIA 實用程式產生正確的設定檔。

  1. 引導至運行等級 3(允許在圖形引導失敗時取得終端):e按引導程式螢幕,然後新增3至行末尾 forlinuxefi並使用 開始引導ctrl + x
  2. 使用您的標準使用者名稱和密碼登入。
  3. 備份任何現有的 Xorg 配置:sudo cp -r /etc/X11/xorg.conf.d /etc/X11/xorg.conf.d.bak
  4. 使用 NVIDIA 的工具建立新的 Xorg 配置:sudo nvidia-xconfig -a
  5. 新的設定檔可能沒有放置在正確的位置。如果/etc/X11/xorg.conf.d/10-nvidia.conf或類似存在,請確保對其進行備份,然後將新的設定檔複製到:(sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.d/10-nvidia.conf 我必須在 Fedora 29 上執行此操作)。
  6. 重啟:sudo reboot

請注意,上面的路徑對應於 Fedora 29,可能需要根據您的發行版儲存這些設定檔的位置進行調整。

相關內容