# concurrent nvidia drivers [solved]

## nativemad

Hi there

I've several pc's over here which are all booted up via a single netboot-image. (nfs, squash, union)

Now i would like to have the right nvidia-drivers version for different gpu's (geforce2 through fx) installed...

Has anyone did something like this before? (i already lookup the vendor via lspci during boot, to get at least the i810 ones working properly with a different xorg.conf)

What would be the easiest way to go? (building binary packages of all nv-drivers and install the right one during boot?)

Thanks in advance!

----------

## NeddySeagoon

nativemad,

You can't do that as the kernel modules all have the same name and you can install at most one kernel module per name.

Hmm ... while I was writing, I thought of a dirty hack.

Name the module files something like nvidia.gf2.ko, nvidia.gf4.ko ... and put them where you like.

Now use 

```
insmod /path/to/nvidia.gf2.ko 
```

to load that module.

If you can use lspci output in a script, you can auto detect the correct driver to load and keep everything common.

Call the script from /etc/conf.d/local.start

You cannot allow xorg to autoload the module as it will look for a file called nvidia in /lib/modules/`uname -r`/...

Even dirtier hack, is to use the above detection to copy the 'right' file to nvidia.ko but that will get really messy.

----------

## SeaTiger

I did lot of that stuff since I build server for diskless client machine.

Playing around with different gpu and monitor settings are PITA. A better solution is the upgrade or downgrade all cards into the same catagory, as long as you are not getting into the 8xxx and 9xxx series, they are pretty cheap now.

----------

## nativemad

I can't exchange all those cards (not all are mine, sometimes low-profile, sometimes onboard, even a laptop)...

Neddyseagoon, thanks for the input, but i'm a bit scared of all the other stuff that comes with the installer... I don't think that this stuff is compatible..?

On the other hand i'm also scared about the boottime with an emerge before X! Even when its binary! 

Are there any other ideas out there?

----------

## SeaTiger

You should not do emerge during boot time, that will be crazy  :Shocked: 

I believe you create a boot partition/directory for those diskless client, copy them and install different drivers in them, you properly need 2 since there are 2 catagories of nvidia drivers. Then in the tftp config send out the corresponding one base on mac addresses.

Nivdia driver is in /usr/lib/opengl/nvidia but you cannot use ln -s to change it during boot time otherwise your next client will properly have the wrong one, especially when they logout of the x session and x window server restart.

BTW, can you explain (or some links) a bit about squash image? Does it work like a ram disk in the client machine? If so maybe a script will works instead of multiple images/directory.

----------

## nativemad

The squash is made almost like http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch

It really like a livecd that comes from the net... As i have a unionfs on top, i can do whatever i like on the client. (a change in the fs is done in clients ram)

The /home is directly rw-mounted via nfs.

It's quite comfortable that way, as you get one image that could be used for netboot or livecd... even a local install of the image works!

If its really just that directory and the module, then i will mess around with a script... (will test that a bit and report back here...)

Thanks so far

----------

## SeaTiger

If the directory /usr/lib/opengl/nvidia is in client machine ram, then yes, we can install one nvidia driver, rename it, then install the other one, rename again. Then use a rc-script to create the soft link during boot time. And has to do the same for the kernel module.

----------

## nativemad

I'm now on the way... 

It took a while to upgrade kde and the kernel, then i've found a bug... https://bugs.gentoo.org/show_bug.cgi?id=223047

However, just to let you know... there are a bit more files included in the drivers:

/usr/lib/xorg/modules/drivers/nvidia_drv.so

/usr/lib/libXvMCNVIDIA.so

/usr/include/cuda

When everything is in place, i will try it with symlinks to the nfs-share (at least the newest driver is a bit large to copy it over to the ram...)

Hopefully this will work as expected!   :Razz: 

Thanks guys!   :Razz: 

----------

## NeddySeagoon

nativemad,

You do not emerge nvidia-drivers at boot time.

At install time you emerge each version of nvidia-drivers in turn.

After the emerge, copy the nvidia.ko file to somewhere outside of /usr/lb/modules/`uname -r`/ and rename it.

The prevents to next emerge nvidia-drivers removing or overwriting the last one.

You now have a set of nvidia driver kernel modules somewhere safe.

At boot time, you detect which one you want to load and use insmod (not modprobe) to load it.

As the kernel module and xorg driver check one anothers versions, you have to so something similar with the xorg part of the nvidia-driver too.

The detection script can be based on grepping lspci, to detect the host hardware.

----------

## nativemad

ok, i've got it working now!   :Razz: 

Jus in case someone would like to know how i did it...

First, we need a directory which holds all directories with de dependent files... Mine is called nv_hack and is avaiable in a live-session under /mnt/cdrom/nv_hack. 

under this dir, i have another dir for each kind of driver (oldest, gf3_4, newest).

Than, one has to emerge all three nvidia driver packages. One by one. After each install, the dependant files (which are shown at the end of each emerge) should be copied over to its directory inclusive its directory structure! like cp /usr/lib/opengl/nvidia/tls/libnvidia-tls.so /mnt/cdrom/nv_hack/newest/usr/lib/opengl/nvidia/tls/libnvidia-tls.so 

When all the files are prepared, the driver can be unmerged...

In /etc/conf.d/local.start i have now the following: A bit ugly, i know, but it works for me!   :Wink: 

```

makenvlinks()

{

cd /mnt/cdrom/nv_hack/$1

declare -a "FILESTOLINK=(`ls -dpx * */*  */*/* */*/*/* */*/*/*/* */*/*/*/*/* `)"

for NVFILE in ${FILESTOLINK[*]}; do

  FILENAME=(`echo $NVFILE | awk -F/ '{print $NF}'`)

  if ! [ -z $FILENAME ] ; then

        PATHTONVFILE=(`echo $NVFILE | sed 's/'$FILENAME'/''/g' `)

        if ! [ -e /$PATHTONVFILE ]; then

           mkdir -p /$PATHTONVFILE

        fi

        cp -sf /mnt/cdrom/nv_hack/$1/$NVFILE /$PATHTONVFILE$FILENAME

  fi

done

cp /mnt/cdrom/nvidia.xorg /etc/X11/xorg.conf

insmod /lib/modules/`uname -r`/video/nvidia.ko

eselect opengl set nvidia

}

VGASTRING=(`lspci | grep VGA`)

NVIDIA=(`echo ${VGASTRING[*]} | grep -i nvidia`)

if ! [ -z $NVIDIA ]; then

    OLDEST=(`echo ${VGASTRING[*]} | grep -i -e TNT -e geforce2`)

    if ! [ -z $OLDEST ]; then

        makenvlinks oldest

    else

        GF3_4=(`echo ${VGASTRING[*]} | grep -i -e geforce3 -e geforce4`)

        if ! [ -z $GF3_4 ]; then

            makenvlinks gf3_4

        else

           makenvlinks newest

        fi

    fi

fi

/etc/init.d/xdm start

```

Thanks guys!   :Razz: 

----------

