2

Background: I've been running Ubuntu for years (started at 16.04, now at 20.04), and been constantly fighting with NVIDA drivers which I need as I use CUDA. As recently as yesterday, my NVIDIA 460 drivers were working fine, and an apt upgrade broke them again: Ubuntu 20.4 update broke my Nvidia 460 driver config


What I want to achieve:

  • Create a restore point of a kernel and its modules (eg nvidia drivers) I'm happy with
  • Whenever NVIDIA drivers break (or something else breaks badly), restore it

What I already have:

  • GRUB which seems to allow choosing specific kernels to boot from

(screenshots for illustration, not reflecting latest version) enter image description here enter image description here


Questions:

  • Restore point containing kernel+modules: is it possible to create (if so how), or am I simply misunderstanding how kernels & modules are managed on linux (ie a kernel wouldn't include the nvidia drivers) ?

  • Restoring from grub: It seems /etc/grub.d/40_custom is the file I want to modify as it's designed specifically for custom menu entries. Do you confirm this is the intended way of booting custom kernels or should I be looking at another file?

/etc/grub.d/40_custom:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
Max
  • 198

2 Answers2

4

The package for the linux kernel is separate from the nvidia drivers. But each kernel version has its corresponding drivers. If you had the nvidia drivers installed for, say, 4.10.0-28, then booting that kernel should use the corresponding drivers.

Other modules may be provided by different packages, e.g., linux-modules-5.8.0-45-generic, linux-modules-extra-5.8.0-45-generic.

So you should already have your "restore point"s, and you can use them via grub, as you show. As for the custom entries in grub, you don't need that for older kernel versions, those are added automatically when updating. You might need that if you want other customization, though.

It is not clear if that is not enough for you, or if that did not work as suitable restore points. Giving a specific example of what did not work for you, if you have any, may help clarifying.

  • I guess the challenges are: knowing which module contains which packages, making sure old kernels don't get deleted and knowing which version to restore (since with apt update new versions can be created without me noticing, and maybe I realize something was broken only several versions later). The lack of answers on my question + challenges make me realize that maybe I'd rather use a imaging tool like Clonezilla to fully control what I backup/restore: https://clonezilla.org/screenshots/?in_path=/00_Clonezilla – Max Mar 19 '21 at 14:34
  • @Max - The "challenges" you pose here look to me like a different issue from what you asked, a question on their own. I will try answering them here, but I suggest using the (edited) question as the place to add them.
    1. Which module contains which packages. See https://askubuntu.com/a/1259815/226614 for an example on how to go from module to package (and how it solved a specific problem).
    2. Making sure old kernels don't get deleted. See https://help.ubuntu.com/community/RemoveOldKernels , depending on your configuration, they might be automatically removed or not...
    – sancho.s ReinstateMonicaCellio Mar 19 '21 at 16:19
  • Knowing which version to restore. As said, there is nothing to restore, it is not like Windows Restore point. You simply boot the version you want.
  • The lack of answers... Well, I guess we are commenting on an answer. I don't know how many answers you consider a satisfactory number.
  • Clonezilla/imaging. That would work ok for many cases, probably including yours. But from what I understood, it would be an overkill for you.
  • Again, if you post a specific example of a case you could not work, that would help.

    – sancho.s ReinstateMonicaCellio Mar 19 '21 at 16:23
  • Thanks Sancho, you're most certainly right. The challenge with Stackexchange is that it forces you to narrow down possibilities to specific questions which might limit you in your search for solutions. Afterthought: the mere fact that kernels can be purged and reside on the OS partition should deter me from using kernels as means of backup/restore. I think disk imaging, although overkill in the sense it might restore unnecessary data, seems considerably simpler/safer (just image the disk to external storage and restore when needed). Nonetheless thx for your answers, I learned a lot. – Max Mar 21 '21 at 07:14