如何为一张 Nvidia 卡上的两个 X 屏幕配置 xorg.conf?

Sto*_*aft 5 xorg multiple-monitors nvidia-geforce xorg.conf gpu-driver

目标

  • 这篇文章的目标:弄清楚将xorg.conf我的每个双显示器用作单独的 X 屏幕需要哪些配置。
  • 这篇文章的中期目标:弄清楚为什么我无法通过手动xorg.conf配置启动 X。
  • 成功指标:当我可以在脚本中启动xeyes或其他 X11 应用程序时,该脚本指定它们出现在我的哪个显示器上。
  • 最终目的:启动 LXC GUI 容器(即完整桌面),以便它们在所选显示器上全屏显示。我希望能够共享键盘并在显示器之间移动光标,但不能移动窗口。

我的系统

  • Ubuntu Server 20.04,Nvidia GT 710 显卡。司机是nvidia-dkms-470-server. 我使用的连接是 HDMI 和 DVI。
  • 系统上还存在其他视频卡,但它们是别名的,将用于直通目的。我不明白为什么这应该是相关的,但视频驱动程序之前已经让我感到惊讶。

预期行为:

  • 当我运行 时startx &,X 应该正常启动,然后我应该能够分别xeyes使用DISPLAY=:0.0或在屏幕 0 或 1 上打开DISPLAY=:0.1

实际行为:

  • 我无法启动 X,并显示“未找到屏幕”。

  • 从日志来看,xf86OpenConsole可能与问题有关,但我不知道那是什么。

  • 这是Xorg.0.log我尝试之后的sudo startx &

[  3083.851] (II) Module nvidia: vendor="NVIDIA Corporation"
[  3083.851]    compiled for 1.6.99.901, module version = 1.0.0
[  3083.851]    Module class: X.Org Video Driver
[  3083.851] (II) UnloadModule: "nvidia"
[  3083.851] (II) Unloading nvidia
[  3083.851] (II) Failed to load module "nvidia" (already loaded, 0)
[  3083.851] (II) LoadModule: "nouveau"
[  3083.852] (WW) Warning, couldn't open module nouveau
[  3083.852] (EE) Failed to load module "nouveau" (module does not exist, 0)
[  3083.852] (II) LoadModule: "modesetting"
[  3083.852] (II) Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so
[  3083.854] (II) Module modesetting: vendor="X.Org Foundation"
[  3083.854]    compiled for 1.20.11, module version = 1.20.11
[  3083.854]    Module class: X.Org Video Driver
[  3083.854]    ABI class: X.Org Video Driver, version 24.1
[  3083.854] (II) LoadModule: "fbdev"
[  3083.854] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
[  3083.855] (II) Module fbdev: vendor="X.Org Foundation"
[  3083.855]    compiled for 1.20.1, module version = 0.5.0
[  3083.855]    Module class: X.Org Video Driver
[  3083.855]    ABI class: X.Org Video Driver, version 24.0
[  3083.855] (II) LoadModule: "vesa"
[  3083.855] (II) Loading /usr/lib/xorg/modules/drivers/vesa_drv.so
[  3083.856] (II) Module vesa: vendor="X.Org Foundation"
[  3083.856]    compiled for 1.20.4, module version = 2.4.0
[  3083.856]    Module class: X.Org Video Driver
[  3083.856]    ABI class: X.Org Video Driver, version 24.0
[  3083.856] (II) NVIDIA dlloader X Driver  470.82.01  Wed Oct 27 21:23:16 UTC 2021
[  3083.856] (II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
[  3083.856] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[  3083.856] (II) FBDEV: driver for framebuffer: fbdev
[  3083.856] (II) VESA: driver for VESA chipsets: vesa
[  3083.856] (WW) xf86OpenConsole: setpgid failed: Operation not permitted
[  3083.856] (WW) xf86OpenConsole: setsid failed: Operation not permitted
[  3083.856] (WW) Falling back to old probe method for modesetting
[  3083.856] (WW) Falling back to old probe method for fbdev
[  3083.856] (WW) Falling back to old probe method for modesetting
[  3083.856] (WW) Falling back to old probe method for fbdev
[  3083.856] (EE) No devices detected.
[  3083.856] (EE) 
Fatal server error:
[  3083.856] (EE) no screens found(EE) 
[  3083.856] (EE) 
Please consult the The X.Org Foundation support 
         at http://wiki.x.org
Run Code Online (Sandbox Code Playgroud)
  • 如果我删除xorg.conf,X 会正常启动,但没有两个 X 屏幕(仅Screen 0),如 xrandr 的输出所示:
~$ sudo xrandr -q
Screen 0: minimum 8 x 8, current 4160 x 1440, maximum 16384 x 16384
VGA-0 disconnected primary (normal left inverted right x axis y axis)
DVI-D-0 connected 1600x1200+0+0 (normal left inverted right x axis y axis) 367mm x 275mm
   1600x1200     60.00*+
   1280x1024     75.02    60.02  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   640x480       75.00    59.94  
HDMI-0 connected 2560x1440+1600+0 (normal left inverted right x axis y axis) 597mm x 336mm
   2560x1440     59.95*+
   2048x1152     60.00  
   1920x1440     60.00  
   1920x1200     59.88  
   1920x1080     60.00    59.94    50.00    60.05    60.00    50.04  
   1680x1050     59.95  
   1440x900      59.89  
   1440x576      50.00  
   1440x480      59.94  
   1280x1024     75.02    60.02  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    70.07    60.00  
   800x600       75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    72.81    59.94    59.93 
Run Code Online (Sandbox Code Playgroud)

第一次尝试

  • xorg.conf基于此制作:https://download.nvidia.com/XFree86/Linux-x86_64/304.137/README/configmultxscreens.html
  • 我怀疑 的监视器部分还需要更多东西xorg.conf,但我不确定它是什么。
  • 我觉得监视器应该Screen以某种方式引用定义,但我对如何做到这一点的随机猜测是徒劳的。
  • 我发现很难将xorg.conf我找到的例子适应我的具体情况。我不知道根据我的硬件或发行版/版本什么是强制性的。
  • /etc/X11/xorg.conf:
Section "Device"
    Identifier "nvidia0"
    Driver "nvidia"
    BusID "PCI:44:00:0"
    Screen 0
EndSection

Section "Device"
    Identifier "nvidia1"
    Driver "nvidia"
    BusID "PCI:44:0:0"
    Screen 1
EndSection


Section "Screen"
    Identifier "Screen0"
    Device "nvidia0"
    Monitor "Monitor0"
    DefaultDepth 24
    Subsection "Display"
        Depth 24
        Modes "1600x1200" "1024x768" "800x600" "640x480"
    EndSubsection
EndSection

Section "Screen"
    Identifier "Screen1"
    Device "nvidia1"
    Monitor "Monitor1"
    DefaultDepth 24
    Subsection "Display"
        Depth 24
        Modes "1600x1200" "1024x768" "800x600" "640x480"
    EndSubsection
EndSection

Section "Monitor"
        Identifier "Monitor0"
EndSection

Section "Monitor"
        Identifier "Monitor1"
        Option "LeftOf" "HDMI-1"
EndSection

Section "ServerLayout"
    Identifier "Main Layout"
    Screen 0 "Screen0"
    Screen 1 "Screen1" leftOf "Screen0"
EndSection
Run Code Online (Sandbox Code Playgroud)

更新-部分成功:

  • xorg.conf使用重新配置nvidia-xconfig
  • 我现在可以开始X
  • 为每台显示器配备 X Screen 并不令人高兴。
  • 我目前的xorg.conf
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 470.82.01


Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    Screen          0
    VendorName     "NVIDIA Corporation"
    Option      "Monitor-DVI-D-0" "DVI"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    Screen          1
    VendorName     "NVIDIA Corporation"
    Option      "Monitor-HDMI-0" "HDMI"
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    SubSection     "Display"
    Depth       24
    EndSubSection
EndSection


Run Code Online (Sandbox Code Playgroud)
  • xrandr仍然只是显示Screen0
~$ sudo xrandr -q
Screen 0: minimum 8 x 8, current 4160 x 1440, maximum 16384 x 16384
VGA-0 disconnected primary (normal left inverted right x axis y axis)
DVI-D-0 connected 1600x1200+0+0 (normal left inverted right x axis y axis) 367mm x 275mm
   1600x1200     60.00*+
   1280x1024     75.02    60.02  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   640x480       75.00    59.94  
HDMI-0 connected 2560x1440+1600+0 (normal left inverted right x axis y axis) 597mm x 336mm
   2560x1440     59.95*+
   2048x1152     60.00  
   1920x1440     60.00  
   1920x1200     59.88  
   1920x1080     60.00    59.94    50.00    60.05    60.00    50.04  
   1680x1050     59.95  
   1440x900      59.89  
   1440x576      50.00  
   1440x480      59.94  
   1280x1024     75.02    60.02  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    70.07    60.00  
   800x600       75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    72.81    59.94    59.93  
Run Code Online (Sandbox Code Playgroud)

编辑:附加说明:我尝试在“设备”部分下提供 PCI ID,例如BusID "PCI:44:0:0". 这实际上似乎是我之前 X 不开头的问题的原因:

[   229.284] (WW) xf86OpenConsole: setpgid failed: Operation not permitted
[   229.284] (WW) xf86OpenConsole: setsid failed: Operation not permitted
Run Code Online (Sandbox Code Playgroud)

另一个更新

BusID我从Device部分中删除了 PCI规范xorg.conf,因为出于某种原因它阻止我启动 X 并出现xf86OpenConsole上述错误。不过我确实注意到 Nvidia 最近的文档建议使用一个ServerLayout部分。我将第二个屏幕添加到此部分,它确实改变了 的输出xrandr,但不是以我想要的方式。它仍然只提到 Screen0,但现在没有关于我的 HDMI 显示器的信息(尽管我有一个光标在上面)。这是现在的输出xrandr

~$ sudo xrandr -q
Screen 0: minimum 8 x 8, current 1600 x 1200, maximum 16384 x 16384
VGA-0 disconnected primary (normal left inverted right x axis y axis)
DVI-D-0 connected 1600x1200+0+0 (normal left inverted right x axis y axis) 367mm x 275mm
   1600x1200     60.00*+
   1280x1024     75.02    60.02  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   640x480       75.00    59.94  
Run Code Online (Sandbox Code Playgroud)

xorg.conf目前的样子是这样的:

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    Screen      1  "Screen1" rightOf "Screen0" 
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS" "DVI"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    Screen          0
    VendorName     "NVIDIA Corporation"
    Option      "Monitor-DVI-D-0" "DVI"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS" "HDMI"
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    Screen          1
    VendorName     "NVIDIA Corporation"
    Option      "Monitor-HDMI-0" "HDMI"
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    SubSection     "Display"
    Depth       24
    EndSubSection
EndSection
Run Code Online (Sandbox Code Playgroud)

编辑:还有一件事:我尝试添加Option "ZaphodHeads"到我的设备部分,但这没有帮助。也许这不是我想要的,或者也许我没有正确配置它,我不知道。

Vin*_*ond 0

我也遇到过同样的问题,并且我很幸运地解决了以下问题xorg.conf。据我所知,它不包含任何特定于设备的信息,因此它应该很容易适应您的情况。

Section "ServerLayout"
    Identifier     "Default Layout"
    Screen      0  "Screen0" 0 0
    Screen      1  "Screen1" RightOf "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
EndSection

Section "Monitor"
    Identifier     "Monitor1"
EndSection

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    Screen          0
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    Screen          1
EndSection

Section "Screen"
    Identifier     "Default Screen"
    Device         "nvidia"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "metamodes" "DFP-0: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "metamodes" "DFP-1: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection
Run Code Online (Sandbox Code Playgroud)

我不完全确定一切都需要,但我还没有时间进行实验。