Kernel Panic

QR Code linking to this page

Written by David Evans, first published (last updated )

Yesterday, I tried to load up one of my reference sites only to be met by a perpetual loading spinner. To keep costs low I run my sites from a single t3.micro EC2 instance, so it’s never going to have 100% uptime. But within that constraint the server should be pretty robust; only being unavailable while restarting after installing updates. Having the site remain down for more than a few seconds is pretty unusual.

Before jumping in to the issue, a selection of the things I’ve done which should keep the server running most of the time:

But in this case, all the services were down, no AWS rules had triggered, and SSH-ing to the machine also stalled. What was going on?

This blog post talks about the debugging and recovery steps I took to get the site back online.

Getting any access at all

With SSH failing, the obvious option was to restart the instance via the AWS UI. But I didn’t want to throw away potentially useful diagnostic information, so step one was to find a way to get more information out, before restarting the instance.

AWS has a small selection of alternative connection options. Most proved useless in this case (for example “Connect with Serial Console” simply showed a blank unresponsive screen), but one allowed me to get the most important bit of information out: an error message.

Within the AWS UI, it’s possible to download a copy of the recent system logs (the information which would be printed to the screen if a monitor were attached to the instance). At time of writing, it’s available in the instance menus at:

Instance → Actions → Monitor and troubleshoot → Get system log

It gave me this:

Debian GNU/Linux 12 ip-*-*-*-* ttyS0

ip-*-*-*-* login: [11649.576377] BUG: kernel NULL pointer dereference, address: 0000000000000000
[11649.579134] #PF: supervisor read access in kernel mode
[11649.581141] #PF: error_code(0x0000) - not-present page
[11649.583137] PGD 0 P4D 0
[11649.584181] Oops: 0000 [#1] PREEMPT SMP PTI
[11649.585811] CPU: 1 PID: 536 Comm: Checkpointer Not tainted 6.1.0-55-cloud-amd64 #1  Debian 6.1.192-1
[11649.589409] Hardware name: Amazon EC2 t3.micro/, BIOS 1.0 10/16/2017
[11649.591861] RIP: 0010:ext4_mb_load_buddy_gfp+0xbc/0x380
[...]
[11649.640894] Call Trace:
[11649.643727]  <TASK>
[11649.646400]  ext4_mb_regular_allocator+0x29e/0xce0
[11649.650038]  ext4_mb_new_blocks+0x820/0x1240
[11649.653443]  ? ext4_find_extent+0x3d3/0x430
[...]
[11649.730753]  ? do_syscall_64+0x69/0x90
[11649.733942]  ? exit_to_user_mode_prepare+0x44/0x240
[11649.737599]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
[...]

That’s a kernel panic… not good. And it looks like it’s happening in the ext4 code (i.e. the filesystem).

A little searching for ext4_mb_load_buddy_gfp and kernel NULL pointer dereference didn’t turn up anything relevant, so I’d have to keep digging.

Knowing this was a full-on kernel panic explained why nothing was able to connect, and suggested nothing will be able to connect. So: might as well reboot the thing and see what happens.

Rebooting

Rebooting the instance via AWS took a long time, but did eventually succeed (presumably after timing out on attempts to perform a graceful shutdown). Once it was back, SSH started working. Great! Let’s get the most important thing out of the way: taking a backup of the latest data.

I have a script on the server which can be used to take a point-in-time backup of everything important: data for various services, application logs, and a bunch of system logs. It collects these all together, tars them up, and stores the bundle ready for SFTP to download. So let’s run that and…

Oh, it froze again. Not a one-off it seems!

Rebooting (again)

OK, after rebooting the thing a second time I took the precaution of shutting down all the application-level services and performing a much more manual backup, finding each set of files that needed to be saved and SFTP-ing them to my local computer individually. It’s a bit laborious but fortunately there aren’t a huge number, and reading the backup script made them all easy to find. In less than a minute I had a full set of files which I could use to rebuild the server if needed, and after a few more minutes I had copies of every log file that might be relevant.

So the main worry is alleviated: if all else fails, I have the latest data and can rebuild the server from scratch (in fact that’s quite an easy task because I scripted it all up long ago). But there’s no point rebuilding a broken thing without understanding why it broke. It’s time to switch to investigation.

Actually: first it’s time to watch a TV show, because my website isn’t so important that it needs to be back online right away. My site isn’t a commercial endeavour and unlike the Microsoft outage a few days ago, nobody’s going to be writing headlines about how my pages are unavailable.

But after the TV show finishes, it’s time for investigation.

Investigation

At this point, my suspicions are quite broad:

Disk

Is the disk full? I’ve had a server become unresponsive before because I forgot to configure it to delete old kernel versions after updating. Once the disk filled up, everything stopped.

Let’s check:

df -h
Filesystem       Size  Used Avail Use% Mounted on
udev             462M     0  462M   0% /dev
tmpfs             95M  440K   95M   1% /run
/dev/nvme0n1p1   7.7G  3.5G  3.8G  48% /
tmpfs            473M     0  473M   0% /dev/shm
tmpfs            5.0M     0  5.0M   0% /run/lock
/dev/nvme0n1p15  124M   12M  112M  10% /boot/efi
tmpfs             95M     0   95M   0% /run/user/1000

Nope, there’s still plenty of space available.

RAM

Is the RAM filling up, and the OOM killer running wild? I’m using zram to get some extra headroom on this tiny (1GB) instance; maybe it broke?

Let’s check: fortunately I have a small program running which captures RAM usage and various other stats every 10 seconds. It creates binary files which I can view as graphs. Here’s a low-resolution view of the available memory around the time it started failing:

Available RAM from the 16th of November to the failure at 19:30 on the 17th.

There’s a spike in swap earlier in the day, but this isn’t the swap getting full; it’s the swap emptying. It also happens at exactly 03:00 UTC, which it just so happens is when the server is configured to automatically restart if an update needs it:

Unattended-Upgrade::Automatic-Reboot-Time "03:00";

Bad software update

Has there been an update which broke something?

Let’s start by checking what has been updated. We already know something important was updated, because of the automatic restart earlier in the day.

We can see the history of updates in /var/log/apt/history.log. The most recent are:

Start-Date: 2026-11-16  06:19:24
Commandline: /usr/bin/unattended-upgrade
Upgrade: linux-libc-dev:amd64 (6.1.190-1, 6.1.192-1)
End-Date: 2026-11-16  06:19:24

Start-Date: 2026-11-16  06:19:25
Commandline: /usr/bin/unattended-upgrade
Install: linux-image-6.1.0-55-cloud-amd64:amd64 (6.1.192-1, automatic)
Upgrade: linux-image-cloud-amd64:amd64 (6.1.190-1, 6.1.192-1)
End-Date: 2026-11-16  06:19:36

Start-Date: 2026-11-16  06:19:37
Commandline: /usr/bin/unattended-upgrade
Remove: linux-image-6.1.0-53-cloud-amd64:amd64 (6.1.187-1)
End-Date: 2026-11-16  06:19:39

That’s a kernel update; linux-image went from 6.1.0-54 to 6.1.0-55 (and the older 6.1.0-53 was removed) — so is anybody else seeing issues with this specific update?

Yes!

It turns out a lot of people have been encountering this over the past couple of days; Debian bug report, Y Combinator thread, Reddit thread.

The symptoms match. I can say with high confidence that this is the cause. And the even better news is that because I’m relatively late to the party, the issue has already been fixed in the next version (6.1.0-56). So let’s just upgrade!

Upgrading

Updating the Debian kernel is a simple task:

sudo apt-get update
sudo apt-get dist-upgrade

Except, running those I got:

Killed

Oh, that’s… curious? I’ve never seen it before. It seems it might be related to running out of memory, but I’ve already seen that there’s still plenty of memory available. I guess I’ll try running it again?

On the second attempt, the command stalled, and the machine became unresponsive. Again.

Downgrading?

So a restart or two later, it seems pushing past the broken version isn’t working. Let’s try to downgrade instead.

I have Debian configured to auto-remove unused packages:

Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";

But thankfully, by default, and for exactly this situation: Debian configures APT to keep the most recent older kernel version marked as “used”. That means I still have version 6.1.0-54 on the machine.

Switching back to the old version is quite easy:

sudo grub-reboot '1>2'
sudo shutdown -r now

The grub-reboot command will set up the GRUB boot-loader to use an alternative boot option (the older kernel in this case) for the next startup only. Then shutdown -r now does its usual thing and restarts the instance.

The magic '1>2' option is telling GRUB to pick option #2 (the index is 0-based), then sub-option #3. In the standard setup, this corresponds to “Advanced options for Debian GNU/Linux” → “Debian GNU/Linux, with Linux [old version]”, but you can confirm by checking the order of items in /boot/grub/grub.cfg:

grep -E '^\s*(menuentry|submenu) ' /boot/grub/grub.cfg
menuentry 'Debian GNU/Linux' [...]
submenu 'Advanced options for Debian GNU/Linux' [...] {
  menuentry 'Debian GNU/Linux, with Linux 6.1.0-55-cloud-amd64' [...]
  menuentry 'Debian GNU/Linux, with Linux 6.1.0-55-cloud-amd64 (recovery mode)' [...]
  menuentry 'Debian GNU/Linux, with Linux 6.1.0-54-cloud-amd64' [...]
  menuentry 'Debian GNU/Linux, with Linux 6.1.0-54-cloud-amd64 (recovery mode)' [...]

So for example '0' is a regular boot, and '1>1' boots into the current kernel version but in recovery mode, etc.

SSH-ing after running those commands confirms that it has successfully downgraded in the welcome message:

Linux ip-*-*-*-* 6.1.0-54-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.190-1 (2026-10-16) x86_64

And running a few test commands confirms that the system is stable now. Most importantly, it’s now possible to upgrade:

sudo apt-get update
sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  linux-image-6.1.0-56-cloud-amd64
The following packages will be upgraded:
  linux-image-cloud-amd64 linux-libc-dev
2 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Great! Version 6.1.0-56 is available, and that includes the fix.

An update (and another restart) later, and the system is running the latest version, and stable again:

Linux ip-*-*-*-* 6.1.0-56-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.192-2 (2026-11-16) x86_64

Timeline

The timeline of this particular incident:

In all, the sites were down from 05:38 to 22:19, with windows of availability within that time of 09:19–10:12 and 13:38–16:52, making a total of ~13 hours of outage. Not great! The main issue which prolonged things was a lack of application-level monitoring: nothing alerted me to the issue until I tried to open a page myself.

But then, this isn’t a commercial site and I would rather not have had to deal with it at 5:40 in the morning anyway. On balance of priorities, a bit of a long outage is mostly fine here, if a little embarrassing. Obviously this is very situation-dependent: if you’re responsible for keeping a commercial site running, it’s a necessity to use a monitoring service which will alert you if the server is not responding to requests.

Why didn’t it auto-recover?

It’s curious that the server didn’t automatically restart immediately after panicking. Some investigation reveals that kernel.panic in /etc/sysctl.d/ is responsible for configuring this, but on my server I already set that to 10, meaning it should restart 10 seconds after a panic (confirmed by checking cat /proc/sys/kernel/panic). And yet we see that the automatic restarts only happen ~3.5 hours(!) after each failure.

I don’t currently have an answer for this, but it is certainly worthy of some investigation, along with the question of whether the server can detect similar failures and automatically roll-back to a previous kernel version.

Lessons Learned

Aside from weaknesses in monitoring (and getting distracted by a TV show) this issue was mercifully simple, but I still learned some useful things along the way:

  1. A great way to get kernel panic logs out of AWS is to use the UI option:

    Instance → Actions → Monitor and troubleshoot → Get system log

  2. APT’s log of package updates is kept in /var/log/apt/history.log

  3. The Debian kernel can be temporarily downgraded by a single version with ease:

    sudo grub-reboot '1>2'
    sudo shutdown -r now
    
  4. Even Debian makes mistakes.