#1135735 nvidia-graphics-drivers: Add helpful pre-install checks to postinst script

#1135735#5
Date:
2026-05-05 10:30:53 UTC
From:
To:
The NVIDIA driver installation often fails silently for new users.
This patch adds read-only pre-install checks to the
nvidia-kernel-support postinst script:

1. Kernel headers present — warns with exact apt command if missing
2. Secure Boot status — explains MOK enrollment steps if enabled
3. Nouveau loaded — warns to reboot after installation

These checks are read-only and do not modify system configuration.
--- debian/nvidia-kernel-support.postinst.in.orig    2026-05-05 
15:25:02.733419459 +0530
+++ debian/nvidia-kernel-support.postinst.in    2026-05-05
15:26:06.968982397 +0530
@@ -4,6 +4,53 @@
  if [ "$1" = "configure" ]
  then

+    # Check if kernel headers are installed
+    if [ ! -d "/lib/modules/$(uname -r)/build" ] && [ ! -d
"/lib/modules/$(uname -r)/source" ]; then
+        echo ""
+        echo "=============================================="
+        echo " NVIDIA Driver Installation - WARNING"
+        echo "=============================================="
+        echo " Kernel headers not found for $(uname -r)."
+        echo " The NVIDIA kernel module cannot be built without them."
+        echo ""
+        echo " Install them with:"
+        echo "   sudo apt install linux-headers-$(uname -r)"
+        echo "=============================================="
+        echo ""
+    fi
+
+    # Check if Secure Boot is enabled
+    if command -v mokutil >/dev/null 2>&1; then
+        if mokutil --sb-state 2>/dev/null | grep -q "SecureBoot
enabled"; then
+            echo ""
+            echo "=============================================="
+            echo " NVIDIA Driver Installation - NOTE"
+            echo "=============================================="
+            echo " Secure Boot is enabled on this system."
+            echo " The NVIDIA kernel module must be signed to load."
+            echo ""
+            echo " After installation, enroll the DKMS key with:"
+            echo "   sudo mokutil --import /var/lib/dkms/mok.pub"
+            echo "   sudo mokutil --import
/var/lib/nvidia/nvidia-modsign-key.pub"
+            echo " Then reboot. The MOK enrollment screen will appear."
+            echo "=============================================="
+            echo ""
+        fi
+    fi
+
+    # Check if nouveau is currently loaded
+    if lsmod 2>/dev/null | grep -q "nouveau"; then
+        echo ""
+        echo "=============================================="
+        echo " NVIDIA Driver Installation - NOTE"
+        echo "=============================================="
+        echo " The open-source 'nouveau' driver is currently loaded."
+        echo " It will be blacklisted automatically."
+        echo " REBOOT after installation to switch to the NVIDIA driver."
+        echo "=============================================="
+        echo ""
+    fi
+
      if [ -f /etc/#PRIVATE#/nvidia-modprobe.conf.dpkg-old ] && [ ! -f
/etc/#PRIVATE#/nvidia-modprobe.conf ]
      then

#1135735#10
Date:
2026-05-21 05:35:34 UTC
From:
To:
On Tue, 5 May 2026 16:00:53 +0530 Ashwin Gundarapu <linuxuser509@zohomail.in> wrote:> Package: nvidia-graphics-drivers
Hi,

Just checking if there's any update on this patch or if any changes are needed. Happy to revise if there are concerns.

Thanks,
Ashwin