Video card set up on Linux can be extremely daunting if the automatic process or graphical tools don’t deliver.  Worse, there are numerous incorrect, incomplete or contradictory sources on the web on how to accomplish this.  In this article we hope to make it clear how to set up multiple Nvidia chipset based video cards and monitors on a single computer using X.

Which Graphics Cards to Use?

Regardless of whether one uses Nvidia-based graphics cards or not, it is recommended to use video cards from the same chipset manufacturer and if possible with the same or similar chipset.  Trying to mix and match cards from different chipset manufacturers adds in far too much variability as they differ widely in features and how well they’re supported in Linux; the same is true for different major lines of chipsets from the same manufacturer (eg, Nvidia GeForce and Quadro chipset lines).

There are several major drawbacks with using multiple Nvidia cards and using two heads on each card, however.  To wit, using two monitors per card and two or more cards requires enabling xinerama, which disables randr and also hardware 2D and 3D acceleration.  You may experience a very noticeable slowdown of your machine as a result, especially if you are rotating the orientation of a monitor.

Firstly and most importantly, the Nvidia video cards must all be capable of running off the same driver.  Probably the best way to do this is to visit Nvidia’s driver download page and determine which drivers are available for each video card, and then compare the lists for each video card to be used to determine the highest driver version available for all the video cards.  This is critical as it is not possible to install two different  versions of the Nvidia graphics driver at the same time on Linux.

In this article’s test case, we used a Gigabyte Nvidia GeForce GT610 (PCIe x16) and an EVGA Nvidia GeForce 6200 (PCI).  Each had one DIV and one VGA video port, and was capable of supporting two monitors simultaneously for a total of four heads.  However, the example in this article will only be using three heads total.

Gigabyte Nvidia GeForce GT610 (PCIe x16)

Gigabyte Nvidia GeForce GT610 (PCIe x16)

EVGA NvidiaGeForce 6200 PCI

EVGA Nvidia GeForce 6200 (PCI)

Choosing a Driver

According to the Nvidia driver download tool, the last driver published for 64bit Linux supporting the GeForce 6200 was 304.88, and this was also the first driver published for 64bit Linux supporting the GT610.  The 304.88 driver is thus the only driver choice available.

Installing the Driver

At this point there are two options: download the driver from Nvidia, or search the standard software repositories for your Linux distro to see if they are already available.  For stability, you should always prefer a driver from your distro’s repositories rather than try to install one manually.

After installing the cards and booting the system, Mint’s “Hardware Drivers” tool listed 304.88 as available for download.  That driver was selected and installed, and the system rebooted to start using the driver.  X can also be restarted by pressing [Alt]+[Ctrl]+[Print Screen]+[K], but this may produce strange results.

Note: Screen resolution and other such features such as rotation can’t be done on the fly with X – it must be restarted after each change.

Configuring X Using the Nvidia X Server Settings Tool

The tool can be found in Mint at Start Menu->Applications->Administration, or you can launch it from the command line by entering nvidia-settings at a terminal prompt.

Firstly disable TwinView (Nvidia’s own implementation for spanning multiple monitorswith one desktop) and enable Xinerama (the X implementation for spanning multiple monitors with one desktop).

Xinerama requires a separate X screen for each monitor.  Select “X Server Display Configuration” from the left hand navigation tree, and then click on each monitor in the “Layout” pane to check the “Enable Xinerama” checkbox.  Each monitor icon will then need to be dragged to where it should be placed relative to the other monitor icons in the “Layout” pane, mirroring the real-world positioning of the physical monitors.

Nvidia X Server Settings Tool

Nvidia X Server Settings Tool

Once the positioning is complete, click the “Save to X Configuration File” button.  The dialog will give you the option to save your current xorg.conf – just enter the file path and name into the text box or browse to where you’d like it to be backed up, or /etc/X11/xorg.conf if you don’t want to back it up.  If the “Merge with existing file” checkbox is checked, any differences between the old and the new file will be commented out but still present in the new file.

Save X Configuration Dialog

Save X Configuration Dialog

Reboot or restart X to check how your new settings look.

Configuring X Manually – Final Tweaks

While the Nvidia X Server Settings tool is handy and provides most of the configuration data for the xorg.conf file, it isn’t perfect – particularly when it comes to correctly aligning monitors with each other.  If one monitor is mirroring another or the mouse won’t move from one monitor to another, it’s likely that this is where the problem lies.  If you open up the Settings tool, you’ll most likely see one monitor on top of another in the Layout pane (if one monitor is completely obscuring another, you can bring it into the foreground by selecting the obscured monitor in the “Selection” select box underneath the “Layout” pane).

Using any text editor as root, open /etc/X11/xorg.conf.  In this example, the file will be opened from the command line in geany:

$ gksudo /etc/X11/xorg.conf &

The xorg.conf used in this article can be found in it’s entirety at the end of the article.

Testing the Xorg.conf Without Rebooting

You can also test your new xorg.conf while still running your old session by starting a new X session on a new display.  When you’re done testing, simply log out.

$ sudo startx -- :1

If the X session freezes or is unusable, you can switch back to your original X session by hitting [CTRL] + [ALT] + [F8] and killing the X session from the command line.

Tweaking the Monitor Layout

A complete explanation of all the config file sections, keywords and options is well beyond the scope of this article.  At this point the only section of major concern is “ServerLayout“, wherein the relationship between monitor positions is defined for Xinerama.  The screens will have unhelpful names like “Screen0″, but more information can be found as to which screen belongs to which monitor by searching out the corresponding Monitor section (eg, “Monitor0″ for “Screen0″).

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "DELL"
    ModelName      "DELL E196FP"
    HorizSync       31.0 - 83.0
    VertRefresh     56.0 - 75.0
    Option         "DPMS"
EndSection

Model names or other information can also be matched up with the “Layout” pane information in the Settings tool.

There are two methods to define relationships.  By default, the Settings tool will use absolute positioning, and do some math with resolutions to determine exactly how many pixels apart each screen should be (ie, the offset).  This produces a “ServerLayout” section like this:

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 1080 0
    Screen      1  "Screen1" 2360 0
    Screen      2  "Screen2" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "1"
EndSection

However, it’s much easier to use relative positioning with keywords such as “RightOf”, like this:

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    Screen      1  "Screen1" RightOf "Screen0"
    Screen      2  "Screen2" LeftOf "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "1"
EndSection

Tweaking the Monitor Resolution

The xorg.conf file likely won’t contain any resolution information, as the Settings tool usually assigns the “Screen” option “metamodes” the value of “nvidia-auto-select“.  “nvidia-auto-select” directs the driver to choose a “reasonable” default based on the hardware information available to it.

Once you know which monitor is assigned to which screen as described in Tweaking the Monitor Layout, you can determine it’s current resolution from the labels in the “Layout” pane of the Settings tool (using the Nvidia driver means that xdpyinfo will report the total desktop resolution across all monitors, and xrandr won’t work at all with xinerama enabled).  A list of all available resolutions for a monitor can be found in the Settings tool by clicking on a monitor in the “Layout” pane and then clicking the “Resolution” selectbox, which will list all available resolutions for that monitor.

NVIDIA X Server Settings - Resolution

NVIDIA X Server Settings – Resolution

You can then manually define the resolution you want to display in the “Screen” section “metamodes” option.  Be extremely careful that you do not specify modes that your monitor is not capable of, as this can damage it!

For a digital display such as DVI or HDMI, it would like this:

Section "Screen"
    Identifier     "Screen2"
    Device         "Device2"
    Monitor        "Monitor2"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "metamodes" "DFP: 1440x900 +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

For an analog display such as VGA, it would look like this (the “60″ is the display refresh rate, and +0+0 is an offset you can use to tweak the position of the display if it isn’t centered correctly on the monitor – ie, the resulting display is a few pixels off the monitor screen):

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "CRT-0"
    Option         "metamodes" "CRT: 640x480 +0+0; CRT: 640x480_60 +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Tweaking the Monitor Rotation

While you can rotate a monitor under Twinview, it will rotate BOTH monitors hooked up to that card which may not be desirable, which leaves xinerama.  And while randr is not supported with xinerama, display rotation is still possible using the “Screen” section’s”metamodes” option flag “Rotation”:

Section "Screen"
    Identifier     "Screen2"
    Device         "Device2"
    Monitor        "Monitor2"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "metamodes" "DFP: nvidia-auto-select +0+0 { Rotation=right }"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

This will rotate the screen, but will fubar the layout by switching the x and y values used to calculate offset if absolute positioning is used in “ScreenLayout” – the offsets will have to be recalculated and entered manually.


 

Appendix A – Sample xorg.conf for Two Nvidia Graphics Cards and Three Monitors

# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 304.88  (buildd@lamiak)  Wed Apr 10 16:20:15 UTC 2013

Section "ServerLayout"
    Identifier     "Layout0"
    #Screen      0  "Screen0" 1080 0
    #Screen      1  "Screen1" 2360 0
    #Screen      2  "Screen2" 0 0
    Screen      0  "Screen0"
    Screen      1  "Screen1" RightOf "Screen0"
    Screen      2  "Screen2" LeftOf "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "1"
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"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor2"
    VendorName     "ASUS"
    ModelName      "Ancor Communications Inc VE228"
    HorizSync       30.0 - 83.0
    VertRefresh     50.0 - 76.0
    Option         "DPMS"
EndSection

Section "Monitor"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor1"
    VendorName     "DELL"
    ModelName      "DELL E173FP"
    HorizSync       31.0 - 80.0
    VertRefresh     56.0 - 75.0
    Option         "DPMS"
EndSection

Section "Monitor"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "DELL"
    ModelName      "DELL E196FP"
    HorizSync       31.0 - 83.0
    VertRefresh     56.0 - 75.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device2"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GT 610"
    BusID          "PCI:1:0:0"
    Screen          1
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce 6200"
    BusID          "PCI:5:4:0"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GT 610"
    BusID          "PCI:1:0:0"
    Screen          0
EndSection

Section "Screen"
    Identifier     "Screen2"
    Device         "Device2"
    Monitor        "Monitor2"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "metamodes" "DFP: nvidia-auto-select +0+0 { Rotation=right}"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "CRT-0"
    Option         "metamodes" "nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"

# Removed Option "metamodes" "CRT: nvidia-auto-select +0+0; CRT: nvidia-auto-select +0+0; CRT: 1280x1024_75 +0+0; CRT: 1152x864 +0+0; CRT: 1024x768 +0+0; CRT: 1024x768_60 +0+0; CRT: 800x600 +0+0; CRT: 800x600_60 +0+0; CRT: 640x480 +0+0; CRT: 640x480_60 +0+0; CRT: nvidia-auto-select @1280x720 +0+0"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "CRT-1"
    Option         "metamodes" "CRT: nvidia-auto-select +0+0; CRT: nvidia-auto-select +0+0; CRT: 1280x1024_75 +0+0; CRT: 1152x864 +0+0; CRT: 1024x768 +0+0; CRT: 1024x768_60 +0+0; CRT: 800x600 +0+0; CRT: 800x600_60 +0+0; CRT: 640x480 +0+0; CRT: 640x480_60 +0+0; CRT: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Extensions"
    Option         "Composite" "Disable"
EndSection

Appendix B – Why Doesn’t the Nvidia Driver + Xinerama Work with RandR?

You may notice messages such as “RandR extension missing” or “Xlib:  extension “RANDR” missing on display”.  This is due to xinerama being deprecated in favour of randr.  However randr does not support a single desktop across multiple monitors; randr only allows one monitor per GPU, and the Nvidia cards are servicing two monitors per GPU.  This makes xinerama the only option for a multiple monitor desktop when using more than one monitor per Nvidia card.