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:
Section "Device"
Identifier "nVidia 1"
Driver "nvidia"
BusID "PCI:2:0:0"
EndSection
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:
Section "Monitor"
Identifier "Monitor 1"
Option "DPMS"
HorizSync 30-75
VertRefresh 30-60
EndSection
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.
Section "Screen"
Identifier "ScreenRight2"
Device "nVidia 3"
Monitor "Dell"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1600x1200" "1280x1024"
EndSubSection
EndSection
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:
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
EndSection
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:
Section "ServerLayout"
Identifier "Multihead"
Screen "ScreenLeft"
Screen "Default Screen" RightOf "ScreenLeft"
Screen "ScreenRight" LeftOf "ScreenLeft"
Screen "ScreenRight2" RightOf "ScreenRight"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
EndSection
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.
Section "ServerFlags"
Option "xinerama" "true"
Option "DefaultServerLayout" "Multihead"
EndSection
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.
Tips
- 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 commandstartx
launches 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.log
which 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 toXorg.0.log.old
and created anew, so be sure to check its contents each time. You can use the commandtail /var/log/Xorg.0.log
to 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!
excellent HowTo...I had also written a almost identical HowTo in the Ubuntu Forums. However, I had not thought of any good tips to help people (aside from the very basics, such as "make a backup of the xorg.conf file") and I found your tips excellent.
ReplyDeleteSo i was wondering if i can copy and paste them to my HowTo?
My preference is that you link to my copy. There are already a number of pages on the ubuntu forums that link here. However, as noted in the copyleft, as long as the ubuntu forums conforms to a creative commons BY-SA compatible license, you are free to use my blog content as you wish.
ReplyDeleteClick on the copyleft link for the specific details.
uhh...sorry, I'm not sure if I understood what you meant, but I did create a link from my thread to your website. You can check my thread here: http://www.ubuntuforums.org/showthread.php?t=221174
ReplyDeleteif you do not like the way I "cited" your site, then I'll remove them promptly
Ugh, trying to make content free and easy for people to use is such a pain in the ass. I guess this is why most places take a default 'no' approach. Anyway, if you plan on aggregating content into a howto, I recommend you look into how the LDP suggests howtos are laid out. Having a separate authors and contributions/acknowledgements section solves most of these problems.
ReplyDeleteOne interesting problem is that the ubuntu forums does not seem to publish a content license. They really ought to do so as it places authors like yourself in a vague situation.
Can you mention how to get X in ubuntu to use a non-default ServerLayout? You say most people will want to make xinerama the default layout, but for those who don't, additional information would be very helpful. I have quite frankly looked everywhere for this information. I knew how to do it in Fedora by setting default runlevel and running startx -- -layout NAME from a text login, but in ubuntu this does not work.
ReplyDeleteNevermind, my problem was in following ubuntuguide.org to modify my .xinitrc. Since I didn't have one, I created it from an empty file and that caused X not to start properly.
ReplyDeleteThere are some additional instructions here, particularly how to edit the xorg.conf in text console mode.
ReplyDeletehttp://doc.gwos.org/index.php/ChangeResolution
Thanks! This worked wonders.
ReplyDeleteJust wondering: I have a laptop setup with:
- Monitor to the left (external) and
- Laptop Monitor.
In Xineramam Mode under ubuntu dapper + gdm all apps are started on th eleft screen which is bad when i'm on the road again... Any idea how i can tweak gdm into starting everything on Screen0 (which is the laptop screen?)
(Card is a radeon rv350)
Woud really appreciate any help as google hasn't turned up anything resourcefull yet. Thanks again!
Fred
Hi,
ReplyDeleteLike Fred J I'm very often on the road and must be able to easily switch my second screen on/off, and switch from "clone" to "extended" mode (for presentations). I'm currently using KUbuntu 7.04 in a VMWare VM on Windows. I'm totally dependent on the flexibility of dual monitors, that's the ONLY reason I'm still using Windows as main OS. I see from this excellent HowTo that it's possible to use dual head, but can anyone confirm that it will do what I need? (easily switch between modes?) My current DELL Latitude D610 has an ATI mobile Radeon X300 card and I preferably use KDE.
Thanks in advance.
Olivier.
Hi,
ReplyDeleteI just wanted to write & say thanks. I had been screwing around, trying to get a dual monitor setup to work on my ubuntu system for the better part of 5 hours before I stumbled accress your tutorial. This was the clearest & most relavent tutorail for the configuration I wanted. After I found your tutorial, I was able to get the dual monitor setup working in under an hour.
I did have a little bit of information to add. Your tutorial covers how to set up a system with multiple video cards controlling multiple monitors. I needed a setup where a single video card controlled 2 monitors. When I followed your instructions, I got the system to boot up & display, but not correctly. I had a duplicate image of the gdm gui on both monitors (2 duplicate desktops with 2 duplicate mouse pointers, both moving in sync & doing the same thing). I needed someting extra & figured it out by a process of trial & error.
My specs:
OS: Ubuntu 6.10
Video Card: ATI Technologies Inc Radeon RV100 QY [Radeon 7000/VE]
Monitors: 2 x DELL 1707FP
I actually got the key idea out of the man pages for xorg.conf.
The subsection for screens under the devices section noted that the 'Screen' option was mandatory for a single PCI entity that would be used to drive more than one display. It also stated that multiple devices sections in the configuration section would be necessary.
I ended up creating 2 "Device" sections, 1 for each screen. There is a lot of duplication between the 2 device sections. For instance , the 2 devices both use the same driver & BusID. The key difference is that one is set to screen 0 & one is set to screen 1.
Here's a copy of the 2 device sections:
Section "Device"
Identifier "Screen0 of ATI Radeon 7000"
Driver "radeon"
BusID "PCI:1:0:0"
Option "MergedFB" "false"
Screen 0
EndSection
Section "Device"
Identifier "Screen1 of ATI Radeon 7000"
Driver "radeon"
BusID "PCI:1:0:0"
Option "MergedFB" "false"
Screen 1
EndSection
I ended up with 2 device sections, 2 monitor sections & 2 screen sections. (Actually' there's more - I kept the defaults available in case my employer repurposes the video card for something else & I need to go back to the builtin).
Hi :) Just wanted to thank you. This was great. I've read maybe 5 articles and YOURS helped a lot. Now my DualHead is working.
ReplyDeleteI found that I needed to turn off the composite function, as the terminal (xterm, gnome, etc) would not come up when I added the second monitor (with a Nvidia card). I guess nvidia does not support it (?). This was added to my xorg.conf,
ReplyDeleteSection "Extensions"
Option "Composite" "false"
EndSection
Thank you. This is the best HowTo on the topic I've read, and I've read more than I'd have liked. And thank you too, Larry Lynn, you saved me a whole lot of hassle!
ReplyDeleteI concur with Norman's observation. This is the only "how to" that I have found that worked.
ReplyDeleteI'm closing comments on this because of overwhelming automated comment spam (about 50/day on this post alone). I'm happy to post your comments if you email them to me directly.
ReplyDelete