Prevent Automatic NVIDIA Driver Updates in Debian Distros

Install an older nvidia graphics driver in Debian Linux and keep it from being overwritten during the next software update.

For those who have older laptops, mine is a BONX7, it may be useful to know HOW TO prevent apt from automatically updating your NVIDIA video driver esp. when the latest driver doesn’t even support your specific hardware and prevents xorg from loading! 🤪

Background

$ cat /etc/os-release
NAME="Pop!_OS"
VERSION="21.10"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 21.10"
VERSION_ID="21.10"
...
$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd0000119Fsv00001558sd00000376bc03sc00i00
vendor   : NVIDIA Corporation
model    : GK104M [GeForce GTX 780M]
driver   : nvidia-driver-390 - distro non-free recommended
driver   : nvidia-driver-418-server - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

In my case, I’d allowed the Pop!_Shop to install all of its updates, which in this case included a major version upgrade of the video driver from v418 to v510. Rebooted and got a black blank screen with some randomly colored graphical artifacts along the middle horizontal of the LCD.

Brilliant.

Neither <ALT><CTRL><Fn> (n=1..5) nor <Super>t got me to a CLI.

The objective here is to get to the CLI in order to clean up this driver mess,
purge the v510 nvidia driver,
prevent the system from ever upgrading the video driver again,
then install the correct driver which does support my legacy card.

Solution

Next stop, pull up a trusty USB stick and boot into PopOS Demo Mode. For those who use System76 hardware, there’s a help page on this subject: https://support.system76.com/articles/pop-recovery/. I used sections Repair through After chroot for the following instructions (though not inclusive of all my research), adjusting for the variables of my specific system.

In your case, make sure you understand what you’re doing and not just copying/pasting text. After all, it is possible that I made a mistake along the way …

$ sudo parted -l

Model: ATA Samsung SSD 840 (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size    Type     File system     Flags
 1      2097kB  496GB  496GB   primary  ext4
 2      496GB   500GB  4295MB  primary  linux-swap(v1)
$ lsblk
NAME          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda             8:0    0 465.8G  0 disk  
├─sda1          8:1    0   512K  0 part  
├─sda2          8:2    0     8G  0 part  
└─sda3          8:3    0 457.8G  0 part  
sdb             8:16   0 465.8G  0 disk  
├─sdb1          8:17   0 461.8G  0 part  /
└─sdb2          8:18   0     4G  0 part

In case your drive is using encryption and lvm, look up system76’s instructions via the link above. The last command below freezes the system76-nvidia-driver from even being installed, let alone updated! When future software updates come along, the system will ignore that driver and you won’t have any more problems.

# mount /dev/sdb1 /mnt
# for i in /dev /dev/pts /proc /sys /run ; do mount -B $i /mnt$i ;  done
# chroot /mnt
# apt-get purge *nvidia*
# apt-get autoremove
# apt-get clean
# apt-mark hold system76-nvidia-driver

Since the ubuntu-drivers command listed early on recommended which driver version to install, that’s what I went with. Else visit https://www.nvidia.com/Download/index.aspx?lang=en-us to check for yourself which driver is most appropriate.

# apt-get install nvidia-driver-390
# exit
# exit
$ reboot

Finis 🧞

Make sure you pick YOUR model number.