The most common multi-head situation is someone having two or more identical monitors. Xinerama takes these and virtually places them alongside each other and creates a virtual desktop that spans them all, thereby combining all their displays into one. However, most programs and window managers assume that your display is a perfect rectangle described simply by its width and height. Therefore anything placed in that area will be visible. Dead space arises when you have one display at say 1280x1024 and another at 640x480, then when placed side by side there is an inaccessible area which is outside the view of either monitor. This non-viewable area cannot be reached by the mouse or the user as they are limited by the edges of the monitors, yet this space is within the 1280x1464 rectangle described by the two monitors side by side.
The good news is that window managers of late have become xinerama aware. The bad news is that some still allow programs to request window placements in dead areas. If you have unequal resolutions, beware.
On to the config. First, assuming you have managed to install the video boards and connect the displays to them, one needs to run the program
lspci. This identifies where each video board is on the system bus. Don't worry if your cards are AGP or such, they'll still show up. Here's an example from one particular system (truncated to ensure fit).
0000:00:1d.7 USB Controller: Intel Corp. 82801DB/DBM ...
0000:00:1e.0 PCI bridge: Intel Corp. 82801 PCI Br...
0000:00:1f.0 ISA bridge: Intel Corp. 82801DB/DBL ...
0000:00:1f.1 IDE interface: Intel Corp. 82801DB/DBL ...
0000:00:1f.3 SMBus: Intel Corp. 82801DB/DBL/DBM ...
0000:01:00.0 VGA compatible controller: ATI Tech...
0000:01:00.1 Display controller: ATI Technol...
0000:02:00.0 VGA compatible controller: nVidia...
0000:02:01.0 VGA compatible controller: nVidia...
0000:02:02.0 VGA compatible controller: nVidia...
0000:02:08.0 Ethernet controller: Intel Corp. 8...
In there, you can see that there is an ATI board, maybe two, and about three nVidia based boards. Each of them has a number at the beginning of it. This is the bus address of the card and it is how we will differentiate between the video cards in the xorg.conf config. In the xorg.conf, you use a Device section to identify each of your video cards. Here is an example of one:
Identifier "nVidia 1"
You can see that the device section has a few necessary elements which are used to name the card, this can be any name, it's just used within the config file to refer to this particular card. We specify what driver to use on the card, in this case it is the nVidia factory linux driver, and finally we specify the BusID of where the card is, exactly. This is copied almost verbatim from the output of
lspci. Even when you are referring to an AGP board, you still identify it as PCI:a:b:c where a,b and c come from the output of lspci.
After you have created an entry for each of your boards, identifying the driver to use, you need to set up Monitors for each of your monitors. Nowdays video cards are good at sussing out the details of each of your displays, so you can often get away with something like the following:
Identifier "Monitor 1"
Here I've told X11 to use DPMS in order to power down the display when it can. This is usually a good idea as monitors can consume over 100 watts of power when running. The exact horizontal and vertical sync values vary by monitor, but most modern displays can communicate their allowable sync ranges over the video cable. Be warned, some fixed frequency monitors can and will be damaged, if you are unsure, run the x configuration tools and set up a single-display system with each of your monitors in turn, saving the contents of the monitor section each time. If you have identical monitors, then you only need one record describing it as the description applies to any version of that monitor attached to any card.
Finally Screens. Screens are combinations of monitors and video card devices. This is how you tell X11 what monitor is connected to which video board, along with what resolutions you want to drive it at.
Device "nVidia 3"
Modes "1600x1200" "1280x1024"
The preceeding example was how I created a screen named ScreenRight2 connected to a dell monitor via the video board named "nVidia 3". I named it ScreenRight2 after a bit of testing determined that it was the second one to the right of my center display. Before I figured that out, it was simply called "Screen 3" because it was the third screen entry in my xorg.conf file.
Once you have a screen entry for each of your displays, you need to bind them all together using a ServerLayout. The ServerLayout is a section which describes all the monitors, their relation to each other and the particular input devices that are being used. Often this is what you will start with:
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
That was the layout that was auto-generated by Ubuntu. Not bad, but it only has one display. Now, for testing purposes, you don't necessarily want to delete that entry. X11 supports multiple selectable layouts in the config file. After that part of your config, create a new layout like so:
Screen "Default Screen" RightOf "ScreenLeft"
Screen "ScreenRight" LeftOf "ScreenLeft"
Screen "ScreenRight2" RightOf "ScreenRight"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
Here, I've named the layout "Multihead", use the same InputDevices as the default layout, but I've added more Screen lines. With them I tell X11 that I have multiple displays and how they relate to each other. Having cleverly named my displays you can see how easily it all fits together. Of course, you never get the names and their relations right at the beginning, so a little bit of testing is needed. Some renaming here and there and you're golden.
Finally, you need to tell X11 that you want to use this different layout and enable xinerama. You can do this by modifying the command line used to launch X11, but most people want this to be their default setup. Therefore you need to edit, or create a ServerFlags entry in your xorg.conf.
Option "xinerama" "true"
Option "DefaultServerLayout" "Multihead"
Here you specify that you want xinerama enabled and you want to use Multihead as the default layout. That way you can override the multihead config on the command line if you want or turn off xinerama, but will otherwise have it on all the time.
- Do not do your config inside of X11. Before you login, press Ctrl-Alt-F1 and login to the text console. There, shutdown the graphical login like this:
sudo /etc/init.d/gdm stop. This way you can edit the xorg.conf and test your setup one piece at a time. The command
startxlaunches X11 as though you had logged in and drops you back to the text console when you 'logout' of the GUI.
- Make a backup of your starting xorg.conf file. Sometimes you just need to start over.
- Baby steps. Make small changes at each step along the way and you'll be guaranteed to have less to undo.
- If something stops working that worked before, go back a step and try something else. Keep notes to guide you.
- There's a file
/var/log/Xorg.0.logwhich contains the output of the X server, examine it and you'll find a treasure trove of information about what's going on under the hood. Every time you restart X11, this file gets renamed to
Xorg.0.log.oldand created anew, so be sure to check its contents each time. You can use the command
tail /var/log/Xorg.0.logto just see the last 10 lines of it in a console.
- Put a post-it note on each monitor with the name you discover it has. It makes life a lot easier to deal with when sorting out what's where.
- Get one display at a time working from start to finish.
- If your system appears locked up, first try to use Ctrl-Alt-Backspace to kill X11. Or, you can use Ctrl-Alt-F1, F2, F3, etc to try to access the other text login prompts.
- If you have configured SSH access to your computer, you can do all your configuration and testing from a laptop.
- If you are really, really screwed, first try pressing Ctrl-Alt-Del and wait 30 seconds to see if init manages to shut-down and reboot your computer. This is the safest way of doing things as it cleanly unmounts the filesystems. However, if you have broken your X11 config, you will have to use the "safe mode" startup to continue your work. This simply bypasses a few steps in the startup, most notably starting the graphical login. From the text console you can copy your original xorg.conf back into place and reboot.
- If even Ctrl-Alt-Del doesn't work, use the SAK. Hold down Alt-PrintScreen (this is the SysRq key combo), and while holding down those keys, press the letters 'S' to sync the disks, then 'U' to unmount the filesystems and 'B' to reboot the computer. Always try that before going for the power button. It's a bit awkward to do all that while holding Alt-PrintScreen, but it's not something you'll do often.
- Relax, your computer isn't likely breaking, you're just dealing with sophisticated hardware drivers and sometimes things go into bad states where the computer doesn't know the video card is in the wrong mode.
- Finally, Google is your friend. If you get odd error messages in the log file, try pasting them into google. Usually someone else has encountered the very problem you are and often has written about it.
- Good luck!