Dual Monitors with NVidia in Ubuntu

Sponsored Link
It's quite a pain to get dual monitors working your first time using Linux, however I hope this guide will make the process relatively quick and painless.

The first step towards dual monitors involves installing the NVidia 3D drivers. Luckily, NVidia has great Linux support and the drivers can easily be downloaded from the Ubuntu repository. Ubuntu Feisty Fawn gives users the option to install these drivers when first installing, but in case you chose not to install these drivers, all it requires is one line of code in the terminal:

sudo apt-get install nvidia-glx

Now that the drivers are installed, let's make sure that we're using them. First, let's check xorg.conf, the main location for display settings in Linux. Type sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_backup. This ensures that we have a backup copy in case some of the settings we're about to edit break X and don't allow you to use a graphical interface! I suggest always doing thins before changing settings in Linux manually to ensure easy recovery later. Now we're ready to edit our settings, so type sudo gedit /etc/X11/xorg.conf. Under the module section, replace "nv" with "glx". Under the device heading, make sure that Driver says "nvidia". Under the screen section, add the following line:

Option "RenderAccel" "true".

Now save your changes and close gedit. We're going to reload X to ensure that we're now using the proper drivers. Reload X by hitting Ctrl+Alt+Backspace. This will require you to log back into Ubuntu, so if you're not using a browser that saves your session, like Firefox/Swifterfox, make sure you bookmark this guide to follow the remaining instructions. If our install worked, you should see the NVidia logo flash quickly before the Ubuntu log in screen comes up. Actually, if this doesn't work, you're not going to be able to load X properly. If that's the case, you're going to have to type this into the console to replace the new xorg.conf with the old:

sudo cp /etc/X11/xorg.conf_backup /etc/X11/xorg.conf

Assuming everything went well, we're quite close to having dual screens working. Let's go back into xorg.conf using sudo gedit /etc/X11/xorg.conf. Now go back under the heading "Screen". Let's add a few lines:

##This turns on NVidia's TwinView
Option "TwinView"
##Here I'm setting the resolution to the individual monitors.
Option "MetaModes" "1280×1024 1280×1024"

That should be it! Restart X with Ctrl+Alt+Backspace and you should have two screens. If the orientation of the screens is off, try this under the "Screen" heading...

Option "TwinViewOrientation" "LeftOf"

LeftOf can be LeftOf, RightOf, Below, Above, or Clone.

Hope that was helpful!

Sponsored Link

Related posts

96 thoughts on “Dual Monitors with NVidia in Ubuntu

  1. This is awesome! I have tried to find a guide to get dual monitors working in any distro of linux for a long time… since RedHat 9 originally came out. This is the first time I was able to get it working! Thanks!

  2. Great stuff!
    Do you know of a way to get the laptop display to be the “main screen” and hold all the menus and stuff…?? Or even if its possible to have separate workspaces on the two screens? 😉

  3. I followed this and got a desktop to display on both screens. But I can’t get my mouse to move to the second desktop.

  4. This articles rocks but digging a little further I found something even sweeter.

    If you’re running the new feisty goodness, try this on for size:

    gksudo nvidia-settings

    I got this tip from http://ubuntuforums.org/showthread.php?p=1773584


    I can only get my laptop to be the main screen if I drag it to the left of the other monitor. Not sure why this is. No way I can see to set one to be the main monitor.

  5. OK, the easiest way to setup dual monitors with nvidia/linux is go to /usr/bin. Type sudo ./nvidia-settings and point an click. The nvidia tool is about as easy as they come. No editing text files, just point and click goodness!


  6. You make no mention of changing refresh rates.
    One needs to change ones “Monitor Section to get correct values if using CRT monitors.
    My moniors are both 1280×1024 but one has a refresh of 72MHz and the other is 75MHz

  7. Okay, I have spent probably a grand total of 24 hours setting up my dual monitors on Ubuntu Feisty Fawn.

    Now, Blender freezes when I try and view a menu, and I get a jacked up screenshot from Warsow… Obviously something is wrong with my settings, but I can’t figure it out.

    I have a GeForce 6200 and Ubuntu 7.04 ? [ Feisty Fawn ]

    Here’s my current xorg.conf

    Sorry about the length, but If anyone can help it would be greatly appreciated.


    Section "ServerLayout"
    Identifier "Default Layout"
    Screen "Default Screen" 0 0
    InputDevice "Generic Keyboard"
    InputDevice "Configured Mouse"
    InputDevice "stylus" "SendCoreEvents"
    InputDevice "cursor" "SendCoreEvents"
    InputDevice "eraser" "SendCoreEvents"

    Section "Files"

    # path to defoma fonts
    FontPath "/usr/share/fonts/X11/misc"
    FontPath "/usr/share/fonts/X11/cyrillic"
    FontPath "/usr/share/fonts/X11/100dpi/:unscaled"
    FontPath "/usr/share/fonts/X11/75dpi/:unscaled"
    FontPath "/usr/share/fonts/X11/Type1"
    FontPath "/usr/share/fonts/X11/100dpi"
    FontPath "/usr/share/fonts/X11/75dpi"
    FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"

    Section "Module"
    Load "bitmap"
    Load "ddc"
    Load "extmod"
    Load "freetype"
    Load "glx"
    Load "int10"
    Load "vbe"
    ## the following are supposed to enable AIGLX
    ## -also blender for dri 6may2007
    Load "dri"
    ##Load "dbe"

    Section "InputDevice"
    Identifier "Generic Keyboard"
    Driver "kbd"
    Option "CoreKeyboard"
    Option "XkbRules" "xorg"
    Option "XkbModel" "pc105"
    Option "XkbLayout" "us"

    Section "InputDevice"
    Identifier "Configured Mouse"
    Driver "mouse"
    Option "CorePointer"
    Option "Device" "/dev/input/mice"
    Option "Protocol" "ImPS/2"
    Option "ZAxisMapping" "4 5"
    Option "Emulate3Buttons" "true"

    Section "InputDevice"
    Identifier "stylus"
    Driver "wacom"
    Option "Device" "/dev/input/wacom"
    Option "Type" "stylus"
    Option "ForceDevice" "ISDV4" # Tablet PC ONLY

    Section "InputDevice"
    Identifier "eraser"
    Driver "wacom"
    Option "Device" "/dev/input/wacom"
    Option "Type" "eraser"
    Option "ForceDevice" "ISDV4" # Tablet PC ONLY

    Section "InputDevice"
    Identifier "cursor"
    Driver "wacom"
    Option "Device" "/dev/input/wacom"
    Option "Type" "cursor"
    Option "ForceDevice" "ISDV4" # Tablet PC ONLY

    Section "Monitor"
    Identifier "Viewsonic 1"
    HorizSync 28.0 - 96.0
    VertRefresh 43.0 - 60.0
    Option "DPMS"

    Section "Device"
    Identifier "nVidia"
    Driver "nvidia"
    ## the following are supposed to enable AIGLX
    ##Option "XAANoOffscreenPixmaps"

    Section "Screen"
    Identifier "Default Screen"
    Device "nVidia"
    Monitor "Viewsonic 1"
    DefaultDepth 24
    Option "TwinView" "True"
    Option "TwinViewOrientation" "RightOf"
    Option "UseEdidFreqs" "True"
    Option "MetaModes" "1280x1024, 1280x1024"
    Option "RenderAccel" "true"
    SubSection "Display"
    Depth 1
    Modes "1920x1440" "1920x1200" "1856x1392" "1792x1344" "1680x1050" "1600x1200" "1440x900" "1400x1050" "1280x1024" "1024x768" "800x600" "640x480"
    SubSection "Display"
    Depth 4
    Modes "1920x1440" "1920x1200" "1856x1392" "1792x1344" "1680x1050" "1600x1200" "1440x900" "1400x1050" "1280x1024" "1024x768" "800x600" "640x480"
    SubSection "Display"
    Depth 8
    Modes "1920x1440" "1920x1200" "1856x1392" "1792x1344" "1680x1050" "1600x1200" "1440x900" "1400x1050" "1280x1024" "1024x768" "800x600" "640x480"
    SubSection "Display"
    Depth 15
    Modes "1920x1440" "1920x1200" "1856x1392" "1792x1344" "1680x1050" "1600x1200" "1440x900" "1400x1050" "1280x1024" "1024x768" "800x600" "640x480"
    SubSection "Display"
    Depth 16
    Modes "1920x1440" "1920x1200" "1856x1392" "1792x1344" "1680x1050" "1600x1200" "1440x900" "1400x1050" "1280x1024" "1024x768" "800x600" "640x480"
    SubSection "Display"
    Depth 24
    Modes "1920x1440" "1920x1200" "1856x1392" "1792x1344" "1680x1050" "1600x1200" "1440x900" "1400x1050" "1280x1024" "1024x768" "800x600" "640x480"

    ## the following are supposed to enable AIGLX
    Section "DRI"
    Mode 0666

    Section "Extensions"
    Option "Composite" "Disable"

  8. nvidia-glx installs OK, but ctrl-alt-backspace fails as it cannot find /dev/nvidia0. The file is there:

    crw-rw—- 1 root video 195, 0 2007-05-25 23:03 /dev/nvidia0

    mods were per above:

  9. And what if you don’t use nvidia, but a Matrox G400 card with dual monitor support. How do you get this running in Ubuntu?

  10. I have dual monitors but not able to get them both with the same resolution. I’m using a NVidia GeForce 7300GS with two Samsung Syncmaster 191T. I have tried to edit xorg.conf but I can only get it to turn on both monitors. I have turn on “TwinView” and MetaModes” “1280×1024 1280×1024”

  11. Hm, nice.

    But I´ve one question left. How can i configure it, to clone the display?
    With TwinView enabled I get one screen witch is split on two displays.
    What I need is the same screen on boths displays: For example: Screen one (Laptop LCD) shows a presentations which shoud be diplayed on Screen two (beamer), too.
    Any ideas how i can achieve this?

  12. Also, I now recommend using gksudo nvidia-settings and clicking on X Server Display Configuration on the left. This tool was not available when I setup dual screens.

    As for the Matrox card or other vendors– it gets far trickier from there on. Without a specific driver like the ATI or NVidia driver I don’t think Linux supports dual monitors.

  13. That nvidia-settings tool is awesome! I was able to set up my new 12.1″ Dell XPS M1210 laptop and 24″ Dell external monitor (which have very different resolutions) with no fuss or mucking around with manually editing files. Thank you so much for bringing it to my attention.

  14. If you use Lenovo T61 + Ubuntu , never install nvidia-glx as suggested. It totally screwed up my NVIDIA module and I had to run “envy” to reinstall a correct NVIDIA driver. However, dual monitor works beautifully after fixing my X configuration following the rest of the instructions

  15. @alan moser

    # Alan Moser Says:
    May 23rd, 2007 at 3:48 am

    OK, the easiest way to setup dual monitors with nvidia/linux is go to /usr/bin. Type sudo ./nvidia-settings and point an click. The nvidia tool is about as easy as they come. No editing text files, just point and click goodness!


    Everybody just do this, it takes about 10 seconds and works exactly as expected.

  16. For all those of you, who want to have a laptop with a beamer (projector), the following may help. When you start the X server without the beamer being connected, and then use nvidia-settings to detect the screen, the maximum resolution of a second display (the beamer) you can get is merely 640×480. After some research and trying I solved it by adding the following options to my xorg.conf file:

    Section “Device”

    Identifier “Videocard0”
    Driver “nvidia”
    Option “ConnectedMonitor” “DFP-0,CRT-0”
    Option “UseDisplayDevice” “DFP-0,CRT-0”
    Option “TwinView” “true”
    Option “TwinViewOrientation” “Clone”
    Option “TwinViewXineramaInfoOrder” “DFP-0,CRT-0”
    Option “MonitorLayout” “LFP,LFP+CRT”
    Option “metamodes” “DFP-0: 1024×768 +0+0, CRT-0: 1024×768 +0+0; DFP-0: 1280×1024 +0+0, CRT-0: 1280×1024 +0+0; DFP-0: 1024×768 +0+0, CRT-0: NULL”


    This is because X server does not detect the second display at the start and you have to force him to think the second display IS there. Without this, and using nvidia-settings I was able only to set the detected display at 640×480 or 320×200.

    Later, when the X-server is started and you connect a beamer, just activate the second screen in nvidia-settings, and it can use much more resolutions than just 640×480.

  17. As a noob and some websites that explained xorg.conf contained the configuration, i figured this out by myself. Great article, which i knew all this a week ago.

    Another note about fixing a scrolling desktop:
    The virtual mode was a problem, my two Samsung 710n flatscreens are 1280×1024 and ubuntu displayed 1600×1400 on both. This made the whole thing scrollable (a view of 1280×1024 following the mouse on a 1600×1400 desktop) and unworkable.
    Solution find the Virtual mode entry in the xorg.conf, and change it to your screen resolution. I had to do this for both screens.

    Another note about enabling desktop effects:
    By default nvidia used xinerama to enable a dualscreen setup. Running “sudo nvidia-settings” gave me the option to choose for twinview, wich works great if both screens have identical resolution. If not, stange behavour regarding windowdocking and maximizing can occur.

  18. Just installed Ubuntu v8.04.
    Followed this guide and worked fine!
    Thank you!

  19. Thank you so much. I was very frustrated with the fact that I couldn’t get a proper dual monitor setup going with the fresh install of Hardy Heron. Being a linux newb who is eager to learn, I found this article immensely helpful.

  20. This is all good and well, but unless you have two monitors that fit together seamlessly, the dual monitor setup gets tired fast. Why? Well whenever you open (most) applications or a dialog box pops up – it’s displayed in the center, split across both screens.

    Does anybody know how to force the positioning of all dialogs/windows to say, the left screen? A quick googling only left me with the impression that Gnome doesn’t like to let you do that, and the Compiz windowing placement plugin isn’t much help either!

  21. Woo-hoo! Works great with Nvidia GeForce 7300 GS on Ubuntu 8.04 with Compiz Fusion going too!

    I’m using the desktop cube and after fidgeting with the compiz settings manager for a bit it’s working in an acceptable way. You’ll want to look at both the general options for desktop size and then the multi output mode options under the cube settings. Multi-output mode “automatic” seems buggy to me. I prefer “multiple cubes”, which is somewhat of a misnomer because they rotate at the same time. It appears from a web search that it’s currently impossible to get multiple completely *separate* cubes that rotate independently.

    One thing… be careful about the quotes above, I copied and paste and didn’t notice the quotes are goofy. Change them to true double quotes.

  22. It still true for Ubuntu 8.04 (Hardly)!!!
    And it’s working perfectly!!!!!

  23. Thanks for the great tutorial!

    I am using an nVidia GeForce 7300GS OC, made by BFG Tech. The OS that I am running is Kubuntu 8.04 (Hardy Heron). Unfortunately, this tutorial did not work for me. Kubuntu hung when trying to restart the X server after adding the Option “RenderAccel” “true” line.

    However, I was able to get dual monitors working. Here is how:

    1. I installed the nvidia-settings program. This is a GUI for configuring your nvidia display. (sudo apt-get install nvidia-settings)
    2. I then ran the GUI (It is under the System menu if you are using Kubuntu 8.04)
    3. I enabled my second monitor in the nvidia-settings program, and set it to Twin View. It worked without restarting the x-server…
    4. However, it set it to Xinerama mode (where when you maximize a window it is spread across both screens). If you like that then you can stop here, however I don’t like that setting, so I did this…
    5. I used the “Save to X Configuration File” option under “X Server Display Configuration” in the nvidia-settings program…
    6. I UNselected the “Merge with existing file” option…
    7. I clicked ‘Show Preview” and then copied and pasted everything into my existing xorg.conf file, using gedit (the reason I had to copy and paste it is because nvidia-settings could not write the xorg.conf file, presumably because I was not running the program as root).
    8. I then restarted the x server by using ctrl+alt+backspace. Worked like a charm!

    Here is the xorg.conf file that the nvidia-settings program created:

    # nvidia-settings: X configuration file generated by nvidia-settings
    # nvidia-settings: version 1.0 ([email protected]) Tue Mar 4 20:24:34 UTC 2008

    Section “ServerLayout”
    Identifier “Layout0”
    Screen 0 “Screen0” 0 0
    InputDevice “Keyboard0” “CoreKeyboard”
    InputDevice “Mouse0” “CorePointer”

    Section “Files”
    RgbPath “/usr/X11R6/lib/X11/rgb”

    Section “Module”
    Load “dbe”
    Load “extmod”
    Load “type1”
    Load “freetype”
    Load “glx”

    Section “ServerFlags”
    Option “Xinerama” “0”

    Section “InputDevice”
    # generated from default
    Identifier “Mouse0”
    Driver “mouse”
    Option “Protocol” “auto”
    Option “Device” “/dev/psaux”
    Option “Emulate3Buttons” “no”
    Option “ZAxisMapping” “4 5”

    Section “InputDevice”
    # generated from default
    Identifier “Keyboard0”
    Driver “kbd”

    Section “Monitor”
    # HorizSync source: edid, VertRefresh source: edid
    Identifier “Monitor0”
    VendorName “Unknown”
    ModelName “HP L1906”
    HorizSync 30.0 – 83.0
    VertRefresh 50.0 – 76.0
    Option “DPMS”

    Section “Device”
    Identifier “Videocard0”
    Driver “nvidia”
    VendorName “NVIDIA Corporation”
    BoardName “GeForce 7300 GS”

    Section “Screen”
    Identifier “Screen0”
    Device “Videocard0”
    Monitor “Monitor0”
    DefaultDepth 24
    Option “TwinView” “1”
    Option “TwinViewXineramaInfoOrder” “CRT-0”
    Option “metamodes” “CRT-0: 1280x1024_60 +0+0, CRT-1: 1280x1024_60 +1280+0”
    SubSection “Display”
    Depth 24

  24. I couldnt set up dual monitors, after modifying xorg.conf and reload x, terminal windows became white squares, also I was unable of moving windows with the “extra” option of visual effects selected. the top windows bar disapeared. However, I did as Josh and I was able to configure dual monitors, but I still cant use the “extra” settings, nautilus doesnt like them.

  25. For someone who’s never really configured anything in Ubuntu, that was straightforward and super easy. Thanks so much for posting this!

Leave a comment

Your email address will not be published. Required fields are marked *