Skip to content

Linux Kernel Panic — Not Syncing Fix

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Linux Kernel Panic. We cover key concepts, practical examples, and best practices.

A Linux kernel panic displays "Kernel panic - not syncing" with a stack trace and freezes the system. This happens when the kernel encounters a fatal error it cannot recover from — typically a bad driver, corrupted initramfs, faulty hardware, or filesystem corruption.

The Problem

On boot or during operation:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Or:

Kernel panic - not syncing: Fatal exception
Kernel Offset: 0x...

Wrong Approach

# WRONG — rebooting without collecting information
sudo reboot

Right Approach

# Capture the panic message for diagnosis
sudo dmesg > kernel-panic-log.txt
# Or take a photo of the screen if the system is frozen

Then boot into a previous kernel from GRUB:

# At GRUB menu, select "Advanced options"
# Choose the previous kernel version

Expected with working kernel:

Normal boot with login prompt.

Step-by-Step Fix

Step 1: Identify the panic cause from the message

Key messages to look for:

Unable to mount root fs → bad root= parameter or missing drivers
Fatal exception → hardware fault or kernel bug
Attempted to kill init → init binary corrupted
Out of memory and no killable processes → OOM panic

Step 2: Boot from an older kernel

At GRUB, select "Advanced options for Ubuntu" and choose a previous kernel.

Step 3: Rebuild initramfs from the working kernel

sudo update-initramfs -u -k all
sudo update-grub

Step 4: Fix root filesystem

# If the panic mentions root fs mounting
sudo fsck -yf /

Step 5: Remove problematic kernel modules

# Boot into recovery mode, then
sudo apt-get purge linux-image-6.x.x-generic
sudo apt-get autoremove
sudo update-grub

Step 6: Check hardware

sudo memtest86+ # Test RAM
sudo smartctl -H /dev/sda # Test disk

Step 7: Add kernel boot parameters

Edit /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="nomodeset acpi=off panic=10"

Then:

sudo update-grub

Prevention Tips

  • Keep at least 2 kernels installed so you can roll back
  • Test kernel updates on a staging system before production
  • Monitor hardware health with SMART checks and memtest
  • Use error-correcting code (ECC) RAM for critical servers
  • Always rebuild initramfs after modifying storage drivers

Common Mistakes with kernel panic

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world LINUX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the most common cause of kernel panic?

The most common cause is a corrupted or missing initramfs after a kernel update, preventing the kernel from mounting the root filesystem. Hardware faults (bad RAM, failing disk) are the second most common trigger.

How do I boot without initramfs?

At the GRUB prompt, manually specify the root partition and kernel parameters: linux /vmlinuz root=/dev/sda1 then initrd /initrd.img then boot. If initrd is corrupted, you may need to specify root filesystem options directly.

Can I set the system to auto-reboot after a panic?

Yes. Set kernel.panic = 10 in /etc/sysctl.conf to make the system reboot 10 seconds after a panic. Add panic=10 to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub for early boot panic handling.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro