Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am booting a certain system of mine with ubuntu 9.10 from external HDD. I am satisfied with the setup and it works fine, however I would like to modify it so that I can choose which graphic card drivers to load during the boot time. Specifically I would like to choose between:

  • nvidia proprietary driver
  • ati proprietary driver
  • generic driver

Currently if I am using proprietary drivers then dont boot into X, delete xorg.conf, start gdm and reconfigure the system using jockey (for hardware drivers).

What would be the steps to make this (semi-)automatic and avoid restarting X?

Where could one find examples of such scripts?

share|improve this question
add comment

4 Answers

up vote 1 down vote accepted
  1. Make 3 different grub entries for each kernel with driver1, driver2, driver3 as options.
  2. Make 3 different xorg.conf (each with one of the three drivers) and name them xorg.conf1, xorg.conf2, xorg.conf2.
  3. Write initscript that executes before X that greps /proc/cmdline for driver1, driver2 oder driver3 and then symlinks xorg.conf1, xorg.conf2 or xorg.conf2 to xorg.conf

I've done something similar to switch between dualheaded and not-dualheaded screensetup in the times before xrandr. Unfortunately the scripts and the documentation is long gone.

Possible improvements:

  • use udev-rules
  • let the initscript auto-detect the current graphics card
share|improve this answer
    
+1 seems the right path. How would you auto-detect? (lspci then insmod?) –  Unreason Sep 14 '10 at 12:39
    
lspci is difficult... Sometimes graphics cards are "Display controller", sometimes they are called "VGA Controller". First thing that came to my mind was "lshw". For example: "lshw | grep -m1 -A5 display | grep vendor" or "lshw -c display | grep vendor" –  bytesum Sep 14 '10 at 13:03
    
thanks –  Unreason Sep 20 '10 at 8:36
add comment

You could always make a shell script that automates that process for you.

share|improve this answer
    
Yes, I would do that, but I am not sure what are all the steps. I do have two different xorg.conf files, but is that enough? should I be also doing some insmods prior to starting gdm? –  Unreason May 31 '10 at 7:22
    
X should load any modules defined in the config file. –  Daenyth Jun 14 '10 at 15:48
    
As Lego399 suggested you can run a script that can load different Xorg config files. Just prepare those config files (xorg.conf.nv, xorg.conf.ati, xorg.conf.vesa) and copy one of them in the xorg.conf original file. After that you can run Xorg server. So you should put this script before gdm starts (or another login manager). –  Pier Jun 15 '10 at 9:28
    
@Pier, actually that was what I did (I have two working xorg.conf files, one for each hardware setup), but that was not enough. I assume that was not enough, as I have to re-run jockey to make things work. –  Unreason Sep 14 '10 at 10:26
add comment

The following might provide some hints at possibly achieving what you want via grub:

http://en.gentoo-wiki.com/wiki/Framebuffer

share|improve this answer
add comment

Create different versions of your xorg.conf based on the stuff you want. Say:

/etc/X11/xorg.conf.nvidia
/etc/X11/xorg.conf.ati
/etc/X11/xorg.conf.generic

Then configure multiple boot configurations in /boot/grub/grub.cfg and put a different kernel parameter (e.g. xconfig=myconfig) in every line where the kernel is specified. Somewhere along the lines of:

menuentry "Ubuntu, Linux 2.6.31-17 nvidia" {
  ...
  linux   /vmlinuz-2.6.31-17 root=UUID=885a6a07-fd6c-4638-aa17-d38997d477e1 xconfig=nvidia ro single
 ...
} 

menuentry "Ubuntu, Linux 2.6.31-17 ati" {
  ...
  linux   /vmlinuz-2.6.31-17 root=UUID=885a6a07-fd6c-4638-aa17-d38997d477e1 xconfig=ati ro single
 ...
}

menuentry "Ubuntu, Linux 2.6.31-17 generic" {
  ...
  linux   /vmlinuz-2.6.31-17 root=UUID=885a6a07-fd6c-4638-aa17-d38997d477e1 xconfig=generic ro single
 ...
}

Kernel parameters that aren't recognized are ignored, but will still be available in /proc/cmdline. Based on this, you can write a small shell script that chooses the correct config file:

#!/bin/bash
rm -f /etc/X11/xorg.conf
config=`cat /proc/cmdline |sed -e 's/.*xconfig=\([a-z]*\).*/\1/g'
ln -s /etc/X11/xonfig.conf.$config /etc/X11/xconfig.conf

Then put this somewhere in your boot order, before gdm starts.

share|improve this answer
    
Oops.. I kind of read the question wrong.. anyway.. :) –  Wouter de Bie Sep 18 '10 at 19:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.