Solved Nvidia driver with multiple kernels

Solved issue

CaffeineAddict

Well-Known Member
Joined
Jan 21, 2024
Messages
1,656
Reaction score
1,155
Credits
13,707
I have 2 kernels installed:

Bash:
dpkg --list | grep linux-image

ii  linux-image-6.7.12+bpo-amd64                             6.7.12-1~bpo12+1                       amd64        Linux 6.7 for 64-bit PCs (signed)
ii  linux-image-6.9.7+bpo-amd64                              6.9.7-1~bpo12+1                        amd64        Linux 6.9 for 64-bit PCs (signed)
ii  linux-image-amd64                                        6.9.7-1~bpo12+1                        amd64        Linux for 64-bit PCs (meta-package)

I'm using only the 6.9.7 one (booted by default) which is recent and the other one is supposed to be used only if recent one fails, or for testing purposes or what ever.

However since I'm installing Nvidia driver from nvidia.com rather than from Debian repo this means when ever Nvidia driver is installed or updated the changes will be applicable only to the recent kernel and the older kernel will not be usable for graphical session.

I think this is so because during driver installation I'm asked whether to rebuild initramfs, I choose "Yes" and this makes the recent kernel boot with the installed driver.
Now I don't fully understand the role of initramfs except that it's updated for the new driver for the recent kernel (or currently booted one? IDK)

What I would like to achieve is to make both kernels usable with Nvidia driver so that which ever I choose in both cases the latest Nvidia driver is loaded and so both kernels are usable for graphical session.
But how to do that? how to update initramfs so that both kernels boot with the driver?

Currently if I attempt to boot older kernel the boot process will stuck because Nvidia driver is not "registered" for that kernel.
Also if new kernel is installed then also Nvidia driver needs to be reinstalled otherwise the only option is to reinstall system because no kernel is configured to boot with the new driver.

Btw. I don't want DKMS, I'd prefer to do this manually if possible, I only want Nvidia driver to be installed so that both kernels are usable with it.

EDIT:
After a bit of research, it seems that during driver installation kernel headers are used to compile the driver, used headers are those for currently loaded kernel and so the driver is built for that kernel.

So if I want it built the driver for both kernels I'd need to boot into each one separately and build the driver twice (for each), however I'm not sure if that will create 2 copies of the driver for each kernel?
I suspect only one driver will be installed, for which ever kernel was loaded last right? because installation procedure uninstalls previous driver.

Also simply updating initramfs for older kernel is unlikely to work because the driver is built for one kernel only.
 
Last edited:


I can't help with Debian or in fact any distro "customization" but it is/was pretty easy with nvidia driver downloaded directly from manufacturer's site.
Install nvidia for the kernel that you run. Next install nvidia for the offline kernel.
Code:
sh NVIDIA-Linux-x86-x.x.x.run -K -k kernel-name -a

Catch, you need to uninstall drivers for the offline kernel before updating.
Note, I was doing this until 2017 (when I had to change laptop and got all Intel) so doublecheck the syntax.

Hopefully will work for you
 
Catch, you need to uninstall drivers for the offline kernel before updating.
Any idea of a location where the is driver installed?
I'd like to make sure 2 drivers for different kernels can be both installed, but in any case I'll test this scenario, already preparing to reinstall system in case if things go wrong.
 
Install nvidia for the kernel that you run. Next install nvidia for the offline kernel.
Code:
sh NVIDIA-Linux-x86-x.x.x.run -K -k kernel-name -a
Catch, you need to uninstall drivers for the offline kernel before updating.
Thank you very much! this works like charm :)

With your help I figured out the -A option will list a ton of installer options, in addition to -K and -k it also mentions option -a is deprecated, so in my case it was sudo ./NVIDIA-Linux-x86_64-x.x.x.run -K -k 6.7.12+bpo-amd64

It's also important to rebuild initramfs when asked by the installer.

Any idea of a location where the is driver installed?
Figured out from here:

The location /lib/modules/$(uname-r)/kernel/drivers/video/ now lists drivers for both kernels.

Thanks @Aristarchus
 
With your help I figured out the -A option will list a ton of installer options, in addition to -K and -k it also mentions option -a is deprecated, so in my case it was sudo ./NVIDIA-Linux-x86_64-x.x.x.run -K -k 6.7.12+bpo-amd64
You should use dkms if you are going to install that driver manually.
 
I really like the project and was already thinking about that if nothing else then to learn more about Linux.

However problem is there won't be package manager and people to maintain packages, something which I don't like to do so I'd need to manually update software and manually check for updates in various code repositories which is time consuming and would need to be done every day afterwards.
 
However problem is there won't be package manager and people to maintain packages, something which I don't like to do so I'd need to manually update software and manually check for updates in various code repositories which is time consuming and would need to be done every day afterwards.
More control with no package manager :p
 


Latest posts

Top