Graphics issues on bare-metal installation

Table of Contents

When Kali receives frequent kernel updates, users who run full upgrades can see DKMS-backed modules (NVIDIA, VirtualBox, some Wi‑Fi drivers) break if the kernel headers for the new version are not installed. This most commonly appears after a kernel upgrade on a system using NVIDIA graphics: on boot the graphical session fails to start and you may see only a blinking cursor or dash.

This document describes safe, repeatable ways to keep kernel headers and DKMS modules in sync, and how to prepare a system for installing proprietary NVIDIA drivers.

This guide assumes you have Kali installed on physical hardware (not a live image). It was written for rolling releases — adapt package names and kernel versioning to your environment where necessary.

1 — Add an APT hook to auto-install headers and rebuild DKMS

Create the file /etc/apt/apt.conf.d/99-kernel-headers-dkms. This causes APT to check the highest kernel version in /lib/modules, attempt to install missing linux-headers for it, and run dkms autoinstall if DKMS is present. The hook is conservative: failures to install headers or build modules are ignored so system upgrades are not blocked.

Safe, minimal example (run as root or with sudo):

kali@kali:~$ sudo tee /etc/apt/apt.conf.d/99-kernel-headers-dkms >/dev/null <<'EOF'
DPkg::Post-Invoke {"bash -c 'set -e; newk=$(ls -1 /lib/modules 2>/dev/null | sort -V | tail -1); if [ -n $newk ] && [ ! -d /usr/src/linux-headers-$newk ]; then echo [apt] Installing headers for $newk >&2; apt-get -y install linux-headers-$newk || true; fi; if command -v dkms >/dev/null; then dkms autoinstall -k $newk || true; fi'";};
EOF
kali@kali:~$

This helps avoid the common case where a kernel upgrade arrives and the matching headers are not yet installed.

2 — One‑time/manual: install headers and rebuild DKMS for the newest kernel

If you just installed a new kernel and want to run the steps immediately (instead of waiting for the next APT run):

# pick the highest installed kernel (not `uname -r`)
kali@kali:~$ newk=$(ls -1 /lib/modules | sort -V | tail -1)

# install headers for that kernel
kali@kali:~$ sudo apt-get update
[...]
kali@kali:~$ sudo apt-get install -y "linux-headers-$newk" || echo "linux-headers-$newk not available"
[...]
# rebuild DKMS modules for that kernel
kali@kali:~$ if command -v dkms >/dev/null; then
  sudo dkms autoinstall -k "$newk"
fi

Tip: if apt-get install can’t find a header package, check that your APT sources include the correct repositories (rolling vs. archive) and that the kernel package actually provides matching headers.

3 — Optional: tune the GRUB kernel command line

You can change the kernel command line for quieter boots or to work around firmware/ACPI issues. Edit /etc/default/grub, update GRUB_CMDLINE_LINUX_DEFAULT, then run update-grub and reboot to test.

Example (changes boot verbosity and adds stricter ACPI handling):

kali@kali:~$ sudo sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi=strict loglevel=3"/' /etc/default/grub
kali@kali:~$ sudo update-grub
[...]
kali@kali:~$

Warning: do not disable ACPI unless you understand your hardware. Disabling ACPI can prevent the kernel from interacting with platform firmware and may cause devices (including the GPU) to not function correctly. Reducing boot verbosity can also make debugging harder.

4 — Disable nouveau before installing NVIDIA drivers

Proprietary NVIDIA packages expect nouveau to be disabled. To blacklist it now and persistently:

# unload nouveau for the running session (may fail if in use)
kali@kali:~$ sudo modprobe -r nouveau || true
[...]
# blacklist nouveau persistently
kali@kali:~$ echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf

# rebuild initramfs so the change takes effect on next boot
kali@kali:~$ sudo update-initramfs -u
[...]
# reboot to make sure nouveau is not loaded on boot
kali@kali:~$ sudo reboot

Warning: If your system requires the open-source driver to boot the graphical environment, ensure you have a recovery plan (TTY access, live USB or recovery media) before blacklisting.

Recovery: to undo the blacklist if the system will not boot into the graphical environment, drop to a TTY (Ctrl+Alt+F3) or use a live USB and run:

sudo rm /etc/modprobe.d/blacklist-nouveau.conf
sudo update-initramfs -u
sudo reboot

5 — Quick steps if you already upgraded and you see a blinking cursor

If you’ve already updated and the system boots to a blinking cursor, use these steps from a TTY (Ctrl+Alt+F3..F6):

  1. Log in with your username and password.
  2. Run the following to update packages and attempt to install headers for the running kernel:
sudo apt update && sudo apt upgrade -y
sudo apt install -y "linux-headers-$(uname -r)" || echo "headers not available for $(uname -r)"
  1. If you have DKMS installed, rebuild modules for the running kernel:
sudo dkms autoinstall -k "$(uname -r)" || true
  1. Reboot:
sudo reboot

Updated on: 2025-Oct-31
Author: Soroush Nekoozadeh