How do I configure nVidia drivers on a Portable Ubuntu setup?

1

1

I've been pulling my hair out over this one for a couple of days now, google is no help.

I've created a wonderful (until this issue) portable copy of Ubuntu linux that will boot on mostly anything by using a USB enclosure for my laptop's 80GB SATA drive. So far so good, it boots and runs on everything, and on non-nVidia card setups was even detecting the drivers, or letting me install the required drivers for hardware acceleration and compiz. Because you know, the wobble windows are the most awesome thing ever.

Anyway, my desktop machine had an nVidia card, so I'm thinking, sure, I'll just install the nVidia drivers like before and everything will work happily. Not so-- now the desktop and any other nVidia cards work great, but it seems to have completely disabled any other graphics cards. When the kernel module detects that an nVidia card isn't present, it shoots up this nasty little dialog box giving me the option to boot into "low graphics" mode, which doesn't even allow me to use the correct screen resolution, much less see the installed graphics card and try to configure a driver for it.

Is there any way to configure Ubuntu (with the dreaded nVidia kernel module) so that it can use nVidia's drivers when an nVidia card is present, and default to the normal (not low-graphics) setup in other cases, so that it has a fair chance of using what's actually present? I'm not afraid to much with config files, I just don't know the underlying system well enough to feel comfortable diving in without a push in the right direction.

Thanks guys!

Nicholas Flynt

Posted 2010-02-27T00:28:03.953

Reputation: 163

Oh: I should mention, I'm using Gnome and a fairly Vanilla Ubuntu setup here. The only exception is the installation of the compiz settings manager, but I don't think that changes anything other than letting me tweak compiz itself. – Nicholas Flynt – 2010-02-27T00:30:16.880

removed the portable-ubuntu tag because that's used for the Portable Ubuntu Remix project. if that's what you are using, feel free to add it back; if you're just using standard Ubuntu on an external drive, ubuntu is the more approprite tag.

– quack quixote – 2010-04-09T21:00:24.193

Answers

2

Here's an init script that will detect if an Nvidia graphics device is present. If there is an NVidia device at boot up it will use an appropriate xorg.conf. If there is not an NVidia device it will use no xorg.conf and let Xorg do its auto-configure thing. Save the following to /etc/init.d/nvidia-check

#!/bin/sh
### BEGIN INIT INFO
# Provides:       nvidia-check
# Required-Start: $local_fs
# Required-Stop:  $local_fs
# Default-Start:  5
# Default-Stop:   0 1 6
# Description:    Check for an nVidia graphics device and setup xorg.conf appropriately
### END INIT INFO

# TODO: nvidiadetector.py from Ubuntu package nvidia-common would probably be more robust here
have_nvidia_vga_device()
{
  lspci | grep VGA | grep -q nVidia
}

start()
{
  if have_nvidia_vga_device ; then
    echo "nVidia device detected."
    if [ -f /etc/X11/xorg.conf.nvidia ]; then
    cp /etc/X11/xorg.conf{.nvidia,}
    else
    echo "ERROR: No nVidia xorg config file missing: /etc/X11/xorg.conf.nvidia"
    return 1
    fi
  else
    echo "No nVidia device detected."
    rm -f /etc/X11/xorg.conf
  fi
}

stop()
{
  if have_nvidia_vga_device && [ -f /etc/X11/xorg.conf ]; then
    echo "Saving nVidia xorg.conf configuration to: /etc/X11/xorg.conf.nvidia"
    # *Move* the xorg.conf file to be "fail safe" at next boot
    mv /etc/X11/xorg.conf{,.nvidia}
  fi
}

case "$1" in
'start')
  start || exit 1
  ;;

'stop')
  stop || exit 1
  ;;

'restart')
  stop || exit 1
  start || exit 1
  ;;
*)
  echo "Usage: $0 {start|stop|restart}"
  exit 1
  ;;
esac

Install with:

sudo chmod +x /etc/init.d/nvidia-check
sudo chkconfig --add nvidia-check

nocnokneo

Posted 2010-02-27T00:28:03.953

Reputation: 161

1

This posting on How to install Nvidia/ATI graphic cards drivers in Ubuntu 9.04 may be useful in identifying what is missing on your system.

I use a similar flash drive installation across two different nVidia systems and a host of other machines. I have also noticed inability to handle graphics on some of the platforms -- this was specifically when on-board Intel graphics based platforms. On several occasions I have tried to bump-up the graphics after booting on the new platform and successfully managed to get drivers to do so.

nik

Posted 2010-02-27T00:28:03.953

Reputation: 50 788

I basically followed those steps, I got my nVidia driver through the Hardware manager. That's the trouble-- now I can't make it go away cleanly. – Nicholas Flynt – 2010-02-27T01:30:14.193

1

AFAIK, when you install the Nvidia drivers, they overwrite your /etc/X11/xorg.conf file to allow (force) you to use the Nvidia driver on subsequent boots. If you revert your xorg.conf file to the previous version (it should have saved a backup in the same directory) you should be able to restore the old behavior. (If you don't have your old xorg.conf file, you can probably get away with removing the one that's there and letting your system auto-detect what driver it needs.)

Unfortunately, I don't think Nvidia's driver will work without specifying that driver in Xorg's configuration. So in order to achieve what you want, you'd probably have to jury rig something that would detect if the system had an Nvidia card before Xorg starts, and then automatically set up the correct Xorg configuration so that Xorg loads the Nvidia driver when it's supposed to.

I'm a bit of a newbie and there might be a better solution that I'm unaware of, but that's my two cents.

nonoitall

Posted 2010-02-27T00:28:03.953

Reputation: 185