Fixing loss of displays or kernel panic after Linux kernel upgrade on PC with NVidia graphics card

1. Introduction

If you are running a PC with Linux and an Nvidia Graphics card, you may experience the problem that the PC restarts after a Linux kernel upgrade, but:

  1. the Nvidia graphics card is not recognized and one cannot use multiple screens (since only the Motherboard graphics card is used)
  2. kernel panic while booting

Therefore, I would to share some short scripts and commands to resolve this issue, which were tested on a HP Workstation Z4G4 with an NVIDIA GeForce RTX 4060 graphics card and Pop! OS (22.04 LTS) Linux.

2. Background

Kernel panics after Ubuntu/Pop!_OS upgrades on NVIDIA systems occur due to interrupted package configurations, missing kernel meta-packages, or mismatched drivers in the initramfs.

Interrupted Packages
Upgrades can fail midway, leaving dpkg in an inconsistent state where packages like systemd are half-configured, causing boot hangs when `dpkg –configure -a` triggers faulty post-install scripts.

Kernel Meta-Package Issues
The `linux-image-generic` meta-package may be absent or broken (e.g., from manual kernel removal), preventing new kernel installation; boot falls back to old kernels without updated modules, leading to root mount failures.

NVIDIA Driver Mismatches
Kernel updates invalidate proprietary NVIDIA modules, which fail to load if not rebuilt in initramfs; this triggers panics during graphics initialization or if nouveau conflicts. [github]()

Systemd and Initramfs Corruption
Systemd corruption blocks init process startup, while outdated initramfs lacks kernel/NVIDIA modules for filesystem access.

2. Nvidia Card not recognized/Multi-screens not recognized

The solution is to reinstall the Nvida graphics driers with the following commands:

#!/bin/sh
#Update the system:
sudo apt update && sudo apt full-upgrade
# Install the System76 NVIDIA driver meta‑package:
sudo apt install system76-driver-nvidia# Reboot:
sudo systemctl reboot

3. Kernel Panic

3.1 Quick Fix

To avoid the kernel panic because an expected driver is not found, you can select a previous kernel version while booting.

3.2 Fix of the new Linux kernel version

To fix the new Linux kernel version, boot into the old kernel version and execute following script:

# Reconfigures any interrupted or broken package installations from the upgrade, which can cause boot failures if dpkg state is inconsistent.
sudo dpkg --configure -a
# Refreshes package lists and applies any pending upgrades, ensuring the system reaches a consistent state before further fixes sudo apt update && sudo apt upgrade -y
# Reinstalls the systemd package to repair any corruption in init system components that might trigger panics during early boot. sudo apt reinstall systemd
# Reinstalls the generic Linux kernel image, fixing missing or mismatched kernel modules often caused by upgrades on NVIDIA hardware. sudo apt install --reinstall linux-image-generic
# Updates the initramfs for all kernels, regenerating initial RAM disks to include necessary NVIDIA drivers and modules for proper root filesystem mounting. sudo update-initramfs -u
# Removes unneeded packages, including old kernels, to prevent GRUB confusion without affecting the boot process sudo apt autoremove
# The commented #sudo update-grub is often unnecessary since initramfs updates handle bootloader integration, but add sudo update-grub if boot issues persist. #sudo update-grub
# For NVIDIA-specific panics, consider purging and reinstalling drivers afterward with 
sudo apt remove --purge '^nvidia.*'
sudo ubuntu-drivers autoinstall
sudo systemctl reboot

Links

[¹] https://www.claudiokuenzler.com/blog/1485/kernel-panic-boot-after-ubuntu-upgrade-missing-kernel-package

[2] https://www.reddit.com/r/debian/comments/1aqn6t3/problems_with_linuximage_update_kernel_panic_help/

[3] https://github.com/pop-os/pop/issues/3525

[4] https://discussion.fedoraproject.org/t/kernel-panic-after-the-systemd-update/150400

http://wilmarigl.de

de_DE_formalGerman