How to Fix Linux Kernel Panic
In this tutorial, you'll learn about How to Fix Linux Kernel Panic. We cover key concepts, practical examples, and best practices.
The Problem
You boot your Linux system and instead of the login screen you see:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
Or:
Kernel panic - not syncing: Attempted to kill init!
exitcode=0x00000100
The system hangs or reboots in a loop. The kernel cannot find or mount the root filesystem, or the init process crashed. A kernel panic is the Linux equivalent of the Windows Blue Screen of Death.
Quick Fix
1. Boot into recovery mode
Most Linux distributions offer a recovery entry in GRUB:
- Restart the system.
- Hold
Shift(BIOS) or pressEsc(UEFI) during boot to enter GRUB. - Select "Advanced options for Ubuntu" (or your distribution).
- Choose a kernel entry with "(recovery mode)".
From the recovery menu, you can:
- Drop to root shell: Run commands to fix filesystem issues.
- Clean: Free up disk space on the boot partition.
- Fsck: Check and repair the root filesystem.
2. Rebuild the initramfs
A corrupted initramfs (initial RAM filesystem) is the most common kernel panic cause. From the recovery root shell:
# Check which kernel is booting
uname -r
# Rebuild initramfs for all kernels
sudo update-initramfs -u -k all
# Or for a specific kernel
sudo update-initramfs -u -k $(uname -r)
On Fedora/RHEL:
sudo dracut --force
After rebuilding, reboot:
sudo reboot
3. Free space on /boot
A full /boot partition prevents the kernel from writing files during updates. Check:
df -h /boot
If it is at 100%, remove old kernels:
# List installed kernels
dpkg --list | grep linux-image
# Remove old kernels (keep the current and one previous)
sudo apt-get purge linux-image-5.4.0-26-generic
# Clean up orphaned packages
sudo apt-get autoremove
Then rebuild initramfs and reboot.
4. Check for bad kernel modules
A recently installed or updated kernel module can cause a panic. In the recovery shell:
# List loaded modules
lsmod | grep -i <suspicious-module>
# Blacklist a problematic module
echo "blacklist <module_name>" | sudo tee /etc/modprobe.d/blacklist-<module>.conf
# Rebuild initramfs
sudo update-initramfs -u
Common problematic modules include proprietary NVIDIA drivers, ZFS modules, and third-party kernel extensions.
5. Boot with an older kernel
If the panic started after a kernel update, boot the previous kernel version:
- Enter GRUB during boot.
- Select "Advanced options for Ubuntu".
- Choose an older kernel entry.
Once booted, remove the problematic kernel:
sudo apt-get purge linux-image-<problematic-version>
sudo update-grub
6. Repair the root filesystem
Corrupted filesystem metadata can trigger a panic at mount time:
# From recovery shell or live USB
sudo fsck -f /dev/sda1
Replace /dev/sda1 with your root partition. Use lsblk or blkid to find it:
lsblk -f
Answer "yes" to repair prompts or use the -y flag for automatic fixes:
sudo fsck -fy /dev/sda1
Then reboot.
Prevention
- Keep at least two kernels installed at all times.
- Monitor
/bootdisk usage and clean old kernels regularly. - Test kernel updates on a non-production system first.
- Back up
/etc/default/gruband/etc/fstabafter making changes. - Use a live USB to repair systems instead of risking data loss from recovery mode.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro