目标

目标

目标

  • 这篇文章的目标:弄清楚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
  • 如果我删除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 

首次尝试

  • 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

更新-部分成功:

  • 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


  • 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  

编辑:补充说明:我尝试在“设备”部分下提供 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

又一次更新

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  

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

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

答案1

我遇到过同样的问题,并且幸运地解决了以下问题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

我不完全确定一切都是必要的,但我还没有时间去尝试。

相关内容