Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What a Kernel Panic Is

When the kernel meets an error it cannot work around, it prints a message that starts with "Kernel panic - not syncing", followed by the reason, and stops. The network and SSH stop with it, so only the console shows the message. Depending on the kernel.panic setting, the server either waits there or restarts after a number of seconds, in which case a panic looks like a reboot loop. A panic is not the same as an application crash or the OOM killer ending a process.

Reach the Console First

On a VPS, open the console in your provider's control panel. On a dedicated server, use the remote console of the IPMI interface; see what is IPMI. Copy or photograph the last lines on the screen, because they decide the next step:

The message mentionsLikely cause
Unable to mount root fsMissing or broken initramfs
Attempted to kill initStartup or root disk failure
Machine checkHardware fault

Before You Change Anything

  1. On a VPS, take a snapshot in your provider's control panel. On a dedicated server, make sure a recent backup exists; see snapshot vs backup.
  2. Note which kernel version failed. It appears in the panic text and in the boot menu.
  3. Keep the older kernel installed, and do not delete files in /boot by hand.

Boot the Previous Kernel

Restart the server from the console. Ubuntu hides the GRUB menu by default: hold Shift during a BIOS boot, or press Esc repeatedly during a UEFI boot. Debian shows the menu for a few seconds. On both, choose the "Advanced options" entry and an older kernel, the normal entry rather than recovery mode. AlmaLinux and Rocky Linux list each installed kernel on the first menu. Once the server is up, check:

uname -r
ls /boot
df -h /boot

If you see a GRUB prompt instead of a menu, follow GRUB rescue.

Cause 1: A Missing or Broken Initramfs

The message "VFS: Unable to mount root fs on unknown-block(0,0)" right after an update almost always means the initramfs for the new kernel is missing, usually because the update was interrupted or /boot was full. Running the old kernel, finish any interrupted package work and rebuild it. KERNEL_VERSION is the failed version, as listed in /lib/modules.

On Ubuntu and Debian (use -c when the file is missing, -u to update an existing one):

sudo dpkg --configure -a
sudo update-initramfs -c -k KERNEL_VERSION
sudo update-grub

On AlmaLinux and Rocky Linux:

sudo dracut -f --kver KERNEL_VERSION

Reinstalling the kernel package, with sudo apt install --reinstall or sudo dnf reinstall, runs the same steps for you.

Cause 2: A Full /boot

A separate, small /boot partition fills up with old kernels, and the next update writes an incomplete initramfs. Make room through the package manager, never by deleting files:

sudo apt autoremove --purge
rpm -q kernel-core
sudo dnf remove kernel-core-OLD_VERSION

The first line is for Ubuntu and Debian. On AlmaLinux and Rocky Linux, list the kernels and remove one old version that is neither running nor your fallback. Then rebuild the initramfs as above. More on updates is in how to update the kernel in Ubuntu.

Cause 3: Hardware on a Dedicated Server

Panics at random times, with different messages or machine check errors, point to hardware: memory, CPU, or disks.

sudo journalctl -k -b -1 | tail -50
sudo ipmitool sel list
sudo smartctl -a /dev/sdX

The journal of the previous boot rarely holds the panic itself, but it often shows the warnings before it, if the journal is kept on disk. The IPMI event log lists memory, CPU, and power events, and smartctl reports disk health. Send what you find to your hosting provider. On a VPS, hardware is the provider's side; report the time and the console text.

Capture the Next Panic with kdump

kdump reserves memory for a second kernel that starts when the first one panics and saves a memory dump to /var/crash for analysis. Install kdump-tools on Debian and Ubuntu. On AlmaLinux and Rocky Linux, install kexec-tools on version 9, or kdump-utils on version 10, and enable the kdump service. Then reboot so the memory is reserved. The reserved memory is lost to applications, so weigh it on a small VPS.

Was this answer helpful?
Loading...