Score:1

How do I configure xorg.conf for two X screens on one Nvidia card?

cn flag

Aims

  • Goal of this post: Figure out what xorg.conf configurations are necessary to use each of my dual monitors as a separate X screen.
  • Intermediate goal for this post: Figure out why I cannot start X with my manual xorg.conf configuration.
  • Success metric: When I can launch xeyes or other X11 apps in a script which specifies which of my monitors they appear on.
  • Ultimate purpose: To start LXC GUI containers (meaning a full desktop) such that they appear fullscreen on a chosen monitor. I wish to be able to share a keyboard and move a cursor between the monitors, but not move windows.

My system

  • Ubuntu Server 20.04, Nvidia GT 710 video card. Driver is nvidia-dkms-470-server. The connections I am using are HDMI and DVI.
  • There are other video cards present on the system, but they are aliased and will be used for passthrough purposes. I see no reason why this should be relevant, but video drivers have surprised me before.

Expected behavior:

  • When I run startx &, X should start normally, and then I should be able to open xeyes on either screen 0 or 1 by using DISPLAY=:0.0 or DISPLAY=:0.1 respectively.

Actual behavior:

  • I cannot start X, with "no screens found".

  • Judging by the logs, xf86OpenConsole might be related to the problem, but I have no idea what that is.

  • This is Xorg.0.log after I try 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
  • If I remove xorg.conf, X starts normally, but without two X screens (only Screen 0), as shown by the output of 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 

First attempts

  • I made my xorg.conf based on this: https://download.nvidia.com/XFree86/Linux-x86_64/304.137/README/configmultxscreens.html
  • I suspect there is something more I need in the monitors section of xorg.conf, but I am not sure what it is.
  • I feel like the monitors should reference the Screen definitions in some way, but my random guesses about how to do that have been fruitless.
  • I am finding it difficult to adapt the xorg.conf examples I have found to my specific circumstances. I don't know what is mandatory based on my hardware or distro/version.
  • /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

Update - partial success:

  • Reconfigured xorg.conf using nvidia-xconfig.
  • I can now start X
  • No joy with respect to actually getting an X Screen for every monitor.
  • My current 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


  • But xrandr still only shows 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  

Edit: One additional note: I have tried supplying the PCI IDs under the "Device" section like BusID "PCI:44:0:0". That actually seems to be the cause of my earlier problem with X not starting with:

[   229.284] (WW) xf86OpenConsole: setpgid failed: Operation not permitted
[   229.284] (WW) xf86OpenConsole: setsid failed: Operation not permitted

Yet another update

I removed the PCI BusID specification from the Device section of xorg.conf, as for some reason it prevented me from starting X with the xf86OpenConsole errors mentioned above. However I did notice that Nvidias more recent documentation suggests using a ServerLayout section. I added the second screen to this section, and it did change the output of xrandr, but not in the way I wanted. It still only mentions Screen0, but now there is no info about my HDMI monitor (although I have a cursor on it). This is now the output of 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  

And my xorg.conf currently looks like this:

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

Edit: One more thing: I tried adding Option "ZaphodHeads" to my Device sections, but that did not help. Perhaps it isn't what I wanted, or maybe I didn't configure it correctly, I don't know.

WinEunuuchs2Unix avatar
in flag
Indeed the settings can be confusing. I always make lots of copies of the configuration while changing it. Something you can try is run the `nvidia-settings` utility and have it generate the configuration file for you.
Stonecraft avatar
cn flag
@WinEunuuchs2Unix but `nvidia-settings` has a truly heinous list of dependencies.
WinEunuuchs2Unix avatar
in flag
Perhaps the configuration generation portion comes in a stand-alone or command line version with less dependencies. Arch Linux usually has good resources: https://wiki.archlinux.org/title/NVIDIA
Stonecraft avatar
cn flag
Oh nice, I see that `nvidia-xconfig` is a thing. That at least gave me a working template, although simply adding second Screen, Device, and Monitor sections did not help, but this at least gives me something to work with.
cn flag
Note that the documentation you are following speaks of a "new" feature called "TwinView", and the example display resolutions are in 4:3 format. This document is older than Xrandr.
Stonecraft avatar
cn flag
@SimonRichter thanks, I did notice that, but I don't think TwinView is what I want. Also there is a more recent document which is essentially the same: https://nvidia.custhelp.com/app/answers/detail/a_id/176/~/linux---configuring-multiple-x-screens-on-one-card
U.V. avatar
cn flag
I gave up on this. I am trying for many years to make this stupid nvidia driver memorize its screen config. I never managed although the configs with its screen offsets looks perfect: Option "metamodes" "HDMI-1: nvidia-auto-select +0+2160, DP-0: nvidia-auto-select +0+0"
alchemy avatar
in flag
Combining `nvidia-xconfig` output and `Xorg -configure` helped me. https://unix.stackexchange.com/questions/146842/regenerate-xorg-conf-with-current-settings
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.