Why my Debian kernel wasn't updating, even when APT reported success
An investigation into missing kernel metapackages, APT's upgrade behaviour and the difference between an installed kernel and a running one.
On this page
- The lab environment
- Scenario 1: APT reports no available updates
- Why the metapackage matters
- Scenario 2: An available kernel update is kept back
- Comparing upgrade behaviour
- Reproducing the misleading patching script
- Correcting the script
- Verifying the package transaction in the logs
- Scenario 3: The new kernel is installed but not running
- What this means for patch management
- References
A patching script can exit successfully without installing an available security update.
I wanted to investigate a particular example of this on Debian: a script that runs apt-get upgrade -y, prints a green success message and leaves the system running an outdated kernel.
I reproduced the problem in a Debian 13 VM in my Incus home lab. In the process, I encountered another way a kernel can fall behind: the kernel metapackage can be missing entirely, leaving APT with nothing to upgrade.
The two problems produce similar symptoms but require different fixes. There is also a third state worth distinguishing: a new kernel can be installed successfully without being the kernel the machine is currently running.
The lab environment
I used a Debian 13 (Trixie) VM with APT 3.0.4 and a 15 GiB virtual disk. The rest of the installed package set was up to date, but I prepared a snapshot with the older kernel and without its metapackage to isolate the kernel update behaviour.
# uname -r
6.12.38+deb13-amd64
# apt --version
apt 3.0.4 (amd64)The VM used the normal Debian stable, security and updates repositories. All tests were performed on 29 November 2026; the candidate versions in the output reflect the repositories at that time.
The terminal output throughout this article is taken from the lab recording, with progress indicators and unrelated package information omitted for readability.
Scenario 1: APT reports no available updates
I refreshed the package lists and simulated an upgrade:
# apt-get update
Hit:1 http://deb.debian.org/debian trixie InRelease
Hit:2 http://deb.debian.org/debian trixie-updates InRelease
Hit:3 http://security.debian.org/debian-security trixie-security InRelease
Reading package lists... Done
# apt-get -s upgrade
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
# apt-get -s upgrade --with-new-pkgs
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.The -s option simulates an operation without making changes to installed packages. Both simulations reported that there was nothing to install. apt list --upgradable also returned no packages.
At this stage, changing the upgrade command made no difference. I needed to investigate the installed packages rather than assume that APT was withholding an update.
# dpkg -l 'linux-image*'
ii linux-image-6.12.38+deb13-amd64 6.12.38-1 amd64 Linux 6.12 for 64-bit PCs (signed)Only one kernel image was installed. I then checked the package policy for linux-image-amd64:
# apt-cache policy linux-image-amd64
linux-image-amd64:
Installed: (none)
Candidate: 6.12.118-1
Version table:
6.12.118-1 500
500 http://security.debian.org/debian-security trixie-security/main amd64 Packages
6.12.117-1 500
500 http://deb.debian.org/debian trixie/main amd64 PackagesThe important line was Installed: (none). A newer kernel metapackage was available from the security repository, but the metapackage wasn’t installed on the VM.
I also checked for held packages and whether the existing kernel was marked as manually installed:
# apt-mark showhold
# apt-mark showmanual | grep '^linux-image'
linux-image-6.12.38+deb13-amd64There were no explicit package holds. The installed kernel was marked as manual, meaning APT treated it as a package explicitly requested rather than an automatically installed dependency. That marking did not prevent upgrades; the missing metapackage was the issue.
Why the metapackage matters
Debian packages kernel images using versioned package names. In this case, the installed package was linux-image-6.12.38+deb13-amd64, whereas the newer image was a separate package called linux-image-6.12.118+deb13-amd64.
APT can upgrade an existing version-specific package when a newer version of that same package is available. It does not automatically infer that a differently named package should replace it.
The linux-image-amd64 metapackage provides that connection. It contains no kernel image of its own; it depends on the appropriate version-specific kernel package. Its name remains constant as its dependency changes.
# apt-cache depends linux-image-amd64
linux-image-amd64
Depends: linux-image-6.12.118+deb13-amd64Without the metapackage, the new image was available but wasn’t required by an installed package. That is why the upgrade simulations had nothing to do.
On a normal affected Debian amd64 system using this kernel flavour, the direct fix would be to review and install the current metapackage:
apt-get -s install linux-image-amd64
apt-get install linux-image-amd64I didn’t do that yet because I wanted to reproduce the second failure mode without immediately installing the newer kernel.
Scenario 2: An available kernel update is kept back
To isolate the effect of the upgrade command, I needed an installed metapackage that still depended on the old kernel.
Debian’s live repositories no longer offered the historical version, but the Debian Snapshot archive did. I temporarily added a repository from 10 August 2025:
cat > /etc/apt/sources.list.d/lab-snapshot.list <<'EOF_SNAPSHOT'
deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/20250810T000000Z/ trixie main
EOF_SNAPSHOT
apt-get update
apt-cache policy linux-image-amd64check-valid-until=no relaxes the repository metadata expiry check for this historical source only. This is a lab setup technique, not a production patching recommendation. Repository signature checks remain enabled.
The old version, 6.12.38-1, was now available alongside the current versions. I inspected its metadata before installing it:
# apt-cache show linux-image-amd64=6.12.38-1
Package: linux-image-amd64
Version: 6.12.38-1
Installed-Size: 13
Depends: linux-image-6.12.38+deb13-amd64 (= 6.12.38-1)The exact dependency was already satisfied by the installed kernel, so only the metapackage needed to be installed. A simulation confirmed this before I made any changes:
# apt-get -s install linux-image-amd64=6.12.38-1
The following NEW packages will be installed:
linux-image-amd64
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.I installed the old version and removed the historical source immediately afterwards:
apt-get install -y linux-image-amd64=6.12.38-1
rm /etc/apt/sources.list.d/lab-snapshot.list
apt-get updateThe kernel itself was unchanged, but APT now recognised an available metapackage upgrade:
# apt-cache policy linux-image-amd64
linux-image-amd64:
Installed: 6.12.38-1
Candidate: 6.12.118-1Comparing dpkg -s linux-image-amd64 with apt-cache show linux-image-amd64 exposed the dependency change:
Installed: linux-image-amd64 (6.12.38-1)
└── linux-image-6.12.38+deb13-amd64 (= 6.12.38-1)
Candidate: linux-image-amd64 (6.12.118-1)
└── linux-image-6.12.118+deb13-amd64 (= 6.12.118-1)The candidate requires a kernel package that isn’t currently installed. The question is whether the upgrade operation is permitted to install it.
Comparing upgrade behaviour
I started with the traditional upgrade command:
# apt-get -s upgrade
The following packages have been kept back:
linux-image-amd64
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.By default, apt-get upgrade neither installs previously uninstalled packages nor removes installed packages. Upgrading the metapackage would require a new kernel image, so APT leaves it at the old version.
Adding --with-new-pkgs changes that behaviour:
# apt-get -s upgrade --with-new-pkgs
The following NEW packages will be installed:
linux-image-6.12.118+deb13-amd64
The following packages will be upgraded:
linux-image-amd64
1 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.The modern apt upgrade command allows new dependencies by default:
# apt -s upgrade
Upgrading:
linux-image-amd64
Installing dependencies:
linux-image-6.12.118+deb13-amd64
Summary:
Upgrading: 1, Installing: 1, Removing: 0, Not Upgrading: 0I also tested the inverse with apt -s upgrade --without-new-pkgs, alongside both full-upgrade variants. All six commands were simulated against the same installed package state.
| Command | New dependencies allowed | Removals allowed | Kernel update scheduled |
|---|---|---|---|
apt-get upgrade |
No | No | No |
apt-get upgrade --with-new-pkgs |
Yes | No | Yes |
apt upgrade |
Yes | No | Yes |
apt upgrade --without-new-pkgs |
No | No | No |
apt-get dist-upgrade |
Yes | Yes | Yes |
apt full-upgrade |
Yes | Yes | Yes |
The full-upgrade variants can remove packages if required to resolve dependencies, although neither proposed any removals in this lab. They weren’t necessary to install this kernel update.
Reproducing the misleading patching script
At this point, I had reproduced the dependency behaviour using simulations. Next, I wanted to see how it manifested in an actual patching script.
I created /root/patch-system.sh:
#!/bin/bash
set -e
apt-get update
apt-get upgrade -y
printf '\033[32mUpdates installed successfully.\033[0m\n'The script uses set -e to stop on a failed command and -y to automatically answer yes to APT’s confirmation prompt. It finishes with a green success message.
Here is what happened when I executed it:
# /root/patch-system.sh
The following packages have been kept back:
linux-image-amd64
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Updates installed successfully.
# echo "Script exit status: $?"
Script exit status: 0APT had explicitly reported that the metapackage was kept back, but it exited successfully. The script continued and printed its success message without installing anything.
Checking the package policy confirmed that 6.12.38-1 was still installed and 6.12.118-1 was still the candidate. The update remained visible in apt list --upgradable.
This is the distinction I wanted to demonstrate: a command completing successfully is not the same as the system reaching the desired state.
set -e cannot help here because APT has not encountered an execution error. It has respected the restrictions of the requested upgrade operation. Similarly, -y controls confirmation prompts; it doesn’t change the dependency policy.
Correcting the script
For unattended scripts, I retained apt-get rather than switching to the interactive apt interface. The only change was allowing new dependencies:
-apt-get upgrade -y
+apt-get upgrade --with-new-pkgs -yRunning the updated script produced a different result:
# /root/patch-system.sh
The following NEW packages will be installed:
linux-image-6.12.118+deb13-amd64
The following packages will be upgraded:
linux-image-amd64
1 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 109 MB of archives.
After this operation, 112 MB of additional disk space will be used.The package installation completed, generated a new initramfs and updated GRUB. The script again returned exit status 0, but this time the requested kernel packages were actually installed.
# apt-cache policy linux-image-amd64
linux-image-amd64:
Installed: 6.12.118-1
Candidate: 6.12.118-1This fixes the specific dependency restriction demonstrated here. It is not a guarantee that every possible future update will be installed: package holds, dependency conflicts and upgrades requiring removals can still need separate attention.
Verifying the package transaction in the logs
APT maintains a transaction history in /var/log/apt/history.log. I checked it to confirm what had actually been installed rather than relying on the script’s output alone.
The history also explained the initial state of the lab. During the earlier VM preparation, the newer metapackage and image had been purged after the installer had already installed them. This was an intentionally prepared test state, not evidence that Debian’s installer normally omits the metapackage.
The relevant subsequent transactions were:
Start-Date: 2026-11-29 07:15:25
Commandline: apt-get install -y linux-image-amd64=6.12.38-1
Install: linux-image-amd64:amd64 (6.12.38-1)
End-Date: 2026-11-29 07:15:25
Start-Date: 2026-11-29 07:17:19
Commandline: apt-get upgrade --with-new-pkgs -y
Install: linux-image-6.12.118+deb13-amd64:amd64 (6.12.118-1, automatic)
Upgrade: linux-image-amd64:amd64 (6.12.38-1, 6.12.118-1)
End-Date: 2026-11-29 07:17:31The successful but ineffective apt-get upgrade -y invocation did not appear as a package transaction in this history. No packages had changed. In this case, the terminal recording was needed to prove that the command had run at all.
I also checked /var/log/dpkg.log for the package state changes and /var/log/apt/term.log for the kernel installation hooks.
These logs answer different questions: the APT history records package transactions, dpkg records package-level state changes, and the APT terminal log contains details emitted during installation and configuration.
Scenario 3: The new kernel is installed but not running
The kernel update had been installed, the candidate matched the installed metapackage and apt list --upgradable was empty. But another check told a different story:
# ls -lh /boot/vmlinuz*
-rw-r--r-- 1 root root 12M Nov 20 12:06 /boot/vmlinuz-6.12.118+deb13-amd64
-rw-r--r-- 1 root root 12M Jul 16 2025 /boot/vmlinuz-6.12.38+deb13-amd64
# uname -r
6.12.38+deb13-amd64Both kernel images were on disk. GRUB had been updated, but the old kernel was still running. Installing a kernel image doesn’t replace the kernel already loaded into memory during boot.
I rebooted the VM and repeated the checks:
# uname -r
6.12.118+deb13-amd64
# apt-cache policy linux-image-amd64
linux-image-amd64:
Installed: 6.12.118-1
Candidate: 6.12.118-1
# apt-get -s upgrade
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.Only now had the VM reached the intended state: the kernel metapackage was installed and current, its new dependency was installed, and the system was running that kernel.
The older kernel remained installed as a potential fallback. I left it in place rather than introducing kernel cleanup into this experiment.
What this means for patch management
The lab demonstrated three independent conditions that can leave a machine running an outdated kernel:
| Condition | What APT might report | What to investigate |
|---|---|---|
| Missing kernel metapackage | No upgrades available | Whether the intended kernel tracking package is installed |
| Upgrade requires a new dependency | Package kept back | The upgrade policy and the candidate’s dependencies |
| Kernel installed but not running | No upgrades available | Running kernel versus installed images and reboot state |
From an infrastructure perspective, I would want patching automation to distinguish a completed command from a verified outcome. At a minimum, it should check whether repository refreshes succeeded, identify outstanding updates, confirm that the expected kernel tracking package is present and report whether the running kernel matches the intended installed version.
Any required reboot should be scheduled and verified according to the system’s maintenance policy. Automatically rebooting a production machine merely because a new kernel has been installed is not necessarily appropriate.
I would also use apt-get update --error-on=any where appropriate to make repository refresh failures more visible to automation. That is a further improvement, not part of the script tested in this experiment. A real patching workflow needs additional safeguards, logging and verification rather than simply replacing one command and keeping the same unconditional success message.
The main lesson is that an exit code is a useful signal, but it is only one part of verifying a system’s state. In this lab, the same exit code represented both an ineffective upgrade and a successful kernel installation. Even after the latter, the machine needed a reboot before it was actually running the updated kernel.