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. Thank you all.

    I managed to get it running for 2 screens and spanning accross.

    Thank you very much

  2. In addition to the instructions above, I followed the instructions here –

    Stage 1: Get the driver working! (1) Install binary driver at console (X will die on startup) a. apt-get install linux-generic (or whatever version you have) b. apt-get install nvidia-glx (2) Enable driver a. sudo nvidia-xconfig โ€“no-composite (3) Check driver with glxinfo

    Then I altered the xorg.conf as follows –

    # nvidia-xconfig: X configuration file generated by nvidia-xconfig
    # nvidia-xconfig: version 1.0 ([email protected]) Tue Aug 1 22:01:29 PDT 2006

    # /etc/X11/xorg.conf (xorg X Window System server configuration file)
    # This file was generated by dexconf, the Debian X Configuration tool, using
    # values from the debconf database.
    # Edit this file with caution, and see the /etc/X11/xorg.conf manual page.
    # (Type “man /etc/X11/xorg.conf” at the shell prompt.)
    # This file is automatically updated on xserver-xorg package upgrades *only*
    # if it has not been modified since the last upgrade of the xserver-xorg
    # package.
    # If you have edited this file but would like it to be automatically updated
    # again, run the following command:
    # sudo dpkg-reconfigure -phigh xserver-xorg

    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/X11/fonts/misc”
    FontPath “/usr/share/X11/fonts/cyrillic”
    FontPath “/usr/share/X11/fonts/100dpi/:unscaled”
    FontPath “/usr/share/X11/fonts/75dpi/:unscaled”
    FontPath “/usr/share/X11/fonts/Type1”
    FontPath “/usr/share/X11/fonts/100dpi”
    FontPath “/usr/share/X11/fonts/75dpi”
    FontPath “/usr/share/fonts/X11/misc”
    FontPath “/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType”

    Section “Module”
    Load “i2c”
    Load “bitmap”
    Load “ddc”
    Load “extmod”
    Load “freetype”
    Load “glx”
    Load “int10”
    Load “type1”
    Load “vbe”

    Section “InputDevice”
    Identifier “Generic Keyboard”
    Driver “kbd”
    Option “CoreKeyboard”
    Option “XkbRules” “xorg”
    Option “XkbModel” “pc105”
    Option “XkbLayout” “us”
    Option “XkbOptions” “lv3:ralt_switch”

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

    Section “InputDevice”

    # /dev/input/event
    # for USB
    Identifier “stylus”
    Driver “wacom”
    Option “Device” “/dev/wacom” # Change to
    Option “Type” “stylus”
    Option “ForceDevice” “ISDV4” # Tablet PC ONLY

    Section “InputDevice”

    # /dev/input/event
    # for USB
    Identifier “eraser”
    Driver “wacom”
    Option “Device” “/dev/wacom” # Change to
    Option “Type” “eraser”
    Option “ForceDevice” “ISDV4” # Tablet PC ONLY

    Section “InputDevice”

    # /dev/input/event
    # for USB
    Identifier “cursor”
    Driver “wacom”
    Option “Device” “/dev/wacom” # Change to
    Option “Type” “cursor”
    Option “ForceDevice” “ISDV4” # Tablet PC ONLY

    Section “Monitor”
    Identifier “XspedVision”
    Option “DPMS”

    Section “Device”
    Identifier “nVidia”
    Driver “nvidia”

    Section “Screen”
    Identifier “Default Screen”
    Device “nVidia”
    Monitor “XspedVision”
    DefaultDepth 24
    Option “RenderAccel” “True”
    Option “TwinView” “True”
    Option “MetaModes” “1440×900,1440×900”
    SubSection “Display”
    Depth 1
    Modes “1440×900” “1280×1024” “1280×960” “1280×800” “1024×768” “832×624” “800×600” “720×400” “640×480”
    SubSection “Display”
    Depth 4
    Modes “1440×900” “1280×1024” “1280×960” “1280×800” “1024×768” “832×624” “800×600” “720×400” “640×480”
    SubSection “Display”
    Depth 8
    Modes “1440×900” “1280×1024” “1280×960” “1280×800” “1024×768” “832×624” “800×600” “720×400” “640×480”
    SubSection “Display”
    Depth 15
    Modes “1440×900” “1280×1024” “1280×960” “1280×800” “1024×768” “832×624” “800×600” “720×400” “640×480”
    SubSection “Display”
    Depth 16
    Modes “1440×900” “1280×1024” “1280×960” “1280×800” “1024×768” “832×624” “800×600” “720×400” “640×480”
    SubSection “Display”
    Depth 24
    Modes “1440×900” “1280×1024” “1280×960” “1280×800” “1024×768” “832×624” “800×600” “720×400” “640×480”

    Section “Extensions”
    Option “Composite” “Disable”

    That’s it. It worked!!

  3. Thank you so much for this tutorial! It works perfectly for me! This is what I was looking for ๐Ÿ™‚

    God Bless <

  4. Thank you, this is a real professional instruction on the net unlike other lame ones. Now I happily enjoy my dual monitor plus exciting 3d effects! ๐Ÿ˜€

  5. Thanks a lot for the tutorial – it works perfectly for me…until I reboot. Then it enters into a low-res mode (of 800×600), and does not detect a second monitor at all. My xorg.conf remains unchanged.
    Anyone has any ideas on what might be happening?

    I have Ubuntu Hardy, GeForce 9600GT, and two Samsung Syncmasters (22- and 19- inch)

    Thanks in advance!

  6. Wow!
    Finally it worked! cant believe this!
    I have a notebook and was really loosing hopes on this…..
    Its working better than windows, for the first time in my Linux experience!
    Great, thx.

  7. Notes about this:
    * worked well for me ๐Ÿ™‚
    * the double quote marks in the web page paste as something strange in the text editor. Type it in yourself.
    * there’s an option not to display the nvidia logo- so the comment about seeing the logo may not work for you.
    * my hardy heron doesn’t have the nvidia-settings program.

  8. Hello!

    Thanks for the post. I setup my two monitors using nvidia-settings and everything works like I want, but I have one little problem. The second screen isn’t always available (used by my girlfriend’s computer when she’s here). My question is, how can I easily switch dual/single monitor configurations?

  9. Ok, I have an 8800gtx and Ubuntu 8.04 and dual monitors went up automatically. However they are just clones. What do I have to do in order to get them to work independently? Thanks.

  10. Man, thanks! Tried a few, way more complicated tutorials before I found this one, with no luck. This was simple and it worked. Mo honor!

  11. A great tutorial, pretty easy to follow, in less than 5 minutes I got compiz running with no problems. The restricted drivers installer that Hardy ships makes this even more easy. Great blog, I’m adding this to my feeds.

  12. i am not able to find โ€œnvโ€ word after typing sudo gedit /etc/X11/xorg.conf ,
    please help me out

  13. I have also gotten dual monitors to work on my dell latitude D830 laptop. Like post 38 above, by sabastien, I have only duel monitors at work, when I bring the laptop home, I lose the second screen. I would like to easily be able to switch between screen configurations, and by easily I mean I’d like it to auto-detect, or at the very least be able to save the configurations to be able to switch at the press of a button.

    Currently I use EnvyNG to install my drivers, which installs the NVidea Config tool. Starting this I can enable/disable the extra monitor. If I forget to do this before I leave work I cannot change it till I get back to work because the menus are all on the left of the screen, which is where my second monitor would be. I know nobody else leaves work in a hurry. j/k

    It would even suffice to have 2 users use different monitor configurations, is this possible?

    Is any of this possible?

  14. Thank you! This worked exactly as advertised. My immediate reason for looking for a solution like yours was that I was suffering from random crashes back to the login screen, which I finally narrowed down to two or more glx apps (like glxgears) running simultaneously. I looked at what I had done months ago, and discovered I was running the Mesa drivers. Why, I asked myself? Well when I tried again installing the non restricted Ubuntu Nvidia drivers (using the synaptic package manager — yes, I’m a weeny) I couldn’t even get one glx app to run — got a strange messsage about the display not being glx enabled. (The mesa drivers had worked just fine for me, other than being slow and this random crash problem.) So I then retried the restricted drivers — these did work but I couldn’t get the nice “clone” look I had gotten for free under the Mesa drivers. Well your solution got it all working. I’m sure a much more clever person than me could have gotten the non-restricted drivers to work, that being the Ubuntu way, but your way was the path of least resistance (and least thrashing/wasted time.) Thanks again. BTW, I’m running Gutsy on a Dell Precision M6300, with a Dell LCD second monitor.

  15. You no longer have to modify xorg.conf manually when getting dual monitors set up. The nvidia-settings program mentioned in an earlier comment does all the heavy lifting. The only issue is you must run it from termial with gksudo to save the xorg.conf file. The settings program doesnt come in with the nvidia drivers so you will have to apt-get it first.

  16. Thanks for the good tutorial, I got it working, however I’m having a problem with my laptop, instead of making the Laptop screen the primary monitor it makes the Second Monitor the Primary monitor, how do I choose which one is primary monitor?

  17. Let me add my thanks for your excellent guidance.

    It works as described.

    I had to go through a couple of steps to get the drivers downloaded and installed…

    a hint to others: if you edit the xorg.conf file and do not find the ‘nv’ ‘glx’ and ‘nvidia’ labels already in place, reload the appropriate driver using “hardware drivers” and restart ubuntu. The xorg.conf file should be updated with the nvidia-specific entries so that you can go through the remainder of the editing steps.

    Thanks again!

  18. Thank you so much! It works perfectly now! You have just made my life so much happier. Thank you, sir.

  19. Hi,

    i fight since hours but at the end my twienview looks not so great ๐Ÿ™ … i have two different resolutions 1600×1200 and 1280×960

    Here a part of my xorg.conf:

    Section “Screen”
    Identifier “Screen0”
    Device “Videocard0”
    Monitor “Monitor0”
    DefaultDepth 24
    Option “TwinView” “1”
    Option “HorizSync” “DFP-0: 30.0-83.0; DFP-1: 30.0-81.0”
    Option “VertRefresh” “DFP-0: 56.0-76.1; DFP-1: 56.0-76.0”
    Option “metamodes” “1600×1200, 1280×[email protected]×960 +1600+240”
    Option “AddARGBGLXVisuals” “True”
    SubSection “Display”
    Depth 24
    Modes “1280×960”

    Now i start my x-server but the second monitor run in a resolution of 1280×1200 … so i can not see all parts … so i add “+240” to see my taskbar …
    can anybody help me or has the same probs ๐Ÿ™ …

    Thanks a lot in advance.

  20. Many many thanks!
    This is the first time I’ve configured Linux for dual screen this quick and without any hassle at all!

  21. Excellent post, thanks!! One problem…

    Got a Dell D830 here, using nvidia-setting to configure second monitor when I need it.

    But, some menus open on the other screen.

    When I use menus on a window that is on the secondary monitor (not the screen that I set ‘Make this the primary display for the X screen’ on), the menu’s open on the primary screen at the edge closest to the secondary one. Would like them to open in the normal place below the pointer.

    Any ideas? Thanks!

Leave a comment

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