2

I have a single SSD I dual-boot with Windows 7 / Ubuntu 11.10. I switch this drive daily between two computers. One is a laptop with integrated Intel graphics. The other is a desktop with an NVIDIA video card.

I want the correct driver to be used and 3D acceleration to be enabled automatically when I boot into Ubuntu on either computer. How do I achieve this?

When I boot Ubuntu with my laptop most drivers start up normally, but GM965 video driver doesn't load, therefore 3D acceleration remains off. The logs show the NVIDIA driver issuing an error about unavailability (looks like it's forcing the NVIDIA driver).

Is normal that Ubuntu 11.10 & Xorg nowadays don't have the same behavior as Windows 7? When I boot Windows 7 the right driver is loaded by PCI identification, and resolution settings are loaded via DDC from the monitor. I think Xorg can do the same thing like when you boot a live CD.

In order to diagnose I need to know how to configure video driver on modern Xorg deployments that deprecates /etc/X11/xorg.conf

Does anyone have any ideas to help me?

Thanks in advance

0

3 Answers 3

4
+100

Bodhi.zazens answer is a step in the right direction, but you'll possibly be unable to use GL capabilities of you Intel card (e.g. desktop effects).

A more polished script that uses the vendor ID of nVidia and corrects the GL library paths is shown below. Before installing this script, you need to save the nvidia xorg configuration to /etc/X11/xorg.conf.nvidia. On the nvidia machine, run the below commands:

sudo nvidia-xconfig
sudo mv /etc/X11/xorg.conf{,.nvidia}

The below script should be saved as /etc/init/auto-gfx-card.conf. When copying, be careful not to put spaces after the trailing backslashes.

description "autoconfigure graphics card settings"
start on (filesystem and (starting lightdm or starting kdm or starting gdm))
script
    # If any nVidia device is found, assume it to be a graphics card
    if [ -n "$(lspci -d10de:)" ]; then
        for arch in x86_64-linux-gnu i386-linux-gnu; do
            # since nvidia drivers have a higher priority, it'll
            # automatically selected as the best available version
            update-alternatives --quiet --force --auto ${arch}_gl_conf || true
        done
        # create the symlink, overwriting existing links if necessary
        ln -sf /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
    else
        # restore Intel GL capabilities
        for arch in x86_64-linux-gnu i386-linux-gnu; do
            update-alternatives --quiet --force --set \
                ${arch}_gl_conf /usr/lib/$arch/mesa/ld.so.conf 2>/dev/null || true
        done
        # remove the symlink if any
        rm -f /etc/X11/xorg.conf
    fi
end script

No further commands are necessary to activate this Upstart job.

3
  • This looks great too, I'm hoping OP tries one or the other and has success. Failing that, I'll do the bonus manually tomorrow based only on votes (This is all way past my skill level, I thought I'd throw some points around and see what happens). Dec 17, 2011 at 22:33
  • @Lekensteyn Thank our for the upstart script. Once the video cards are working, an upstart script is a much better solution.
    – Panther
    Dec 18, 2011 at 0:49
  • 4 votes to 3 after 24 hours so thanks to both for the great answers, bounty's over. Dec 18, 2011 at 18:53
3

It is a messy hack, and there is probably a cleaner method (ie writing a nice upstart init script), but ...

Assuming both the nvidia driver and intel card are working ;)

Use a script in /etc/rc.local to use the correct xorg.conf. The intel card should not need a xorg.conf, so save the working nvidia xorg.conf at say /etc/X11/xorg.conf.nvida

While running the nvidia machine

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

Then add this to /etc/rc.local

# determine if we have a nvidia card, $VIDEO will be an empty sting with the intel card
VIDEO=$(lspci | grep nVidia)

# test if $VIDEO is empty, and move xorg.conf if needed
if [ -n "$VIDEO" ]
    then
        # if xorg.conf exists, remove it.
        [[ -e /etc/X11/xorg.conf ]] && rm -f /etc/X11.xorg.conf
    else
        # if xorg.conf does not exist copy it
        [[ -e /etc/X11/xorg.conf ]] || cp /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
 fi

 # restart lightdm, need to modify for kdm or gdm
 /etc/init.d/lightdm restart

Depending on how fast rc.local runs you may be able to skip the lightdm restart altogether or if it runs too early you may need to add a sleep.

If you need an xorg.conf for the intel card, simply modify the script to put the correct xorg.conf into place.

The only other potential problem would be if the nvidia kernel module conflicts with the intel driver (unlikely), in that event we would need to blacklist drivers, which can be done with a custom stanza in grub.

8
  • Beautiful, thanks. I'll wait about 24 hours to see if this helps the OP, then do the bounty manually if needed. Side note - I've never seen anyone gain as many points as fast as you, but I'm glad to contribute to the total. Dec 17, 2011 at 18:53
  • We really need input from Jairo Andres Velasco Ro (OP). My script can be modified (obviously) and perhaps someone will have a better solution. Thanks for the complement, I have always enjoyed helping people learn Ubuntu, been around for a while, just in other venues (new to ask ubuntu).
    – Panther
    Dec 17, 2011 at 18:56
  • Think you should use restart lightdm in the last line (it's an Upstart job :)) or maybe just move it to pre-start script ... end script in /etc/init/lightdm.conf.
    – htorque
    Dec 17, 2011 at 20:04
  • The idea is good, but you must keep in mind that /etc/rc.local is run with dash and therefore cannot use bashism like [[. lspci returns multiple words. If you use [ -n $VIDEO ], you'll get an error like "[: 1: 01:00.0: unexpected operator". Quote it properly: [ -n "$VIDEO" ]
    – Lekensteyn
    Dec 17, 2011 at 21:37
  • thanks for your support, but xorg.conf switching not works because it is an empty file. Xorg is autodetecting hardware, the prob is that it is selecting i915 driver on laptop. I need confirm if someone has GM965 opengl 3d acceleration and which driver used. Dec 17, 2011 at 22:23
1

This is probably a bad idea. You can't use the NVIDIA driver with your laptop's integrated Intel graphics. Since you have the unusual practice of sharing a single SSD between two different computers, you should probably stick with the 'lowest common denominator' here, which is the default video drivers.

If you still want to install and configure the restricted NVIDIA drivers, do so on the desktop, which has a compatible video card.

Click the gear icon, top right of your screen and choose 'System settings...' then click on 'Additional Drivers'. This will show you any available or enabled proprietary drivers from NVIDIA, like this:

NVIDIA Drivers enabled

To access the settings for the card after installing the drivers, type 'NVIDIA' in the dash, like this:

NVIDIA settings dash

This brings up the driver's settings screen. Make any changes you want here and then click the 'Save to X configuration file, like shown here:

NVIDIA X config

For more on configuring X here is the Ubuntu X/Config wiki page

Be aware that if you do this you may run into problems on the laptop, which does not have a NVIDIA card.

8
  • Thanks Tom, I have the nvidia driver enabled when I use my desktop, but I checked the log xorg and I look that driver loaded for my intel chipset is the 'i915' driver (thats the string shown) but my chipset is the GM965. Do I need something to install right 965 driver? it exists? 965 is pretty popular chip on many laptops today, doesnt ubuntu include it? Dec 16, 2011 at 2:48
  • Probably it's supported. What you are trying to do is to install drivers for both video cards/chips and have the correct one used at boot, depending on which computer the drive is in. I don't know if that is possible. My advice above would only have your desktop working perfectly. You need to confirm that 3D acceleration is even possible with the integrated graphics on the laptop. There is some hardware support documentation online, but it is a work in progress and does not cover everything. Sorry I can't be more help. Let's try a bounty tomorrow and see what happens... Dec 16, 2011 at 10:52
  • Is the GM965 working ?
    – Panther
    Dec 17, 2011 at 16:00
  • @bodhi.zazen I'm hoping the OP returns and provides more info. I think the GM965 is working, but without 3D acceleration. I thought it was an interesting question anyway. My answer is rubbish so I'm hoping someone else can answer with the best practice for this situation. Dec 17, 2011 at 16:36
  • Your answer is a good one, using the open source drivers is the way to go, would then work out of the box. If we are going to get into using nvidia and intel closed drivers we at a minimum are going to need 2 xorg.conf and a boot script to detect the graphics card in use and use one or the other xorg.conf. We may need custom grub entries to blacklist various drivers if they conflict. Would be nice to start with working X first ;)
    – Panther
    Dec 17, 2011 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .