Fix Kernel Panic: VFS Unable to Mount Root Filesystem
Kernel panic with 'VFS: Unable to mount root fs' occurs when the kernel cannot locate or mount the root filesystem. This guide covers causes and step-by-step recovery using a live CD.
Symptoms
During system boot, the console displays a kernel panic with a message similar to:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)The system fails to reach the login prompt and may hang or reboot. This occurs immediately after the kernel loads the initial RAM disk (initramfs/initrd).
Root Causes
- Missing or corrupted initramfs/initrd: The initial RAM disk does not contain the necessary modules (e.g., filesystem driver, storage controller driver) to mount the root filesystem.
- Incorrect root= parameter in kernel command line: The bootloader (GRUB) passes a wrong root device (e.g., wrong UUID or device name).
- Filesystem corruption on root partition: The root filesystem is damaged and cannot be read.
- Missing storage driver: The kernel lacks the driver for the storage controller (e.g., NVMe, SATA, RAID) in the initramfs.
- Bootloader misconfiguration: GRUB configuration points to a non-existent or incorrect kernel or initramfs.
Step-by-Step Fix
Prerequisites
- Boot from a live Linux USB/CD (e.g., Ubuntu Live, SystemRescue).
- Identify your root partition using
lsblkorfdisk -l.
Step 1: Check and Repair Filesystem
- Unmount the root partition if mounted:
umount /dev/sdXY - Run filesystem check:
fsck -y /dev/sdXY(replace sdXY with your root partition, e.g., sda2). - If errors are found and fixed, reboot and test.
Step 2: Verify Kernel Command Line
- Mount the root partition:
mount /dev/sdXY /mnt - Chroot into the system:
chroot /mnt - Check GRUB configuration:
cat /boot/grub/grub.cfg | grep root= - Ensure the
root=parameter uses the correct UUID or device. Update/etc/default/grubif needed, then runupdate-grub(Debian/Ubuntu) orgrub-mkconfig -o /boot/grub/grub.cfg(others).
Step 3: Rebuild Initramfs
- While chrooted, rebuild the initramfs:
- On Debian/Ubuntu:
update-initramfs -u -k all - On RHEL/CentOS/Fedora:
dracut -f - On Arch:
mkinitcpio -p linux
- On Debian/Ubuntu:
- Exit chroot:
exit, then reboot.
Step 4: Reinstall Bootloader
- If GRUB is corrupted, reinstall it:
- Mount the EFI partition (if UEFI):
mount /dev/sdXY /mnt/boot/efi - Chroot:
chroot /mnt - Reinstall GRUB:
grub-install /dev/sdX(replace sdX with disk, e.g., sda). - Update GRUB:
update-grub
- Mount the EFI partition (if UEFI):
Alternative Fixes
- Use fallback initramfs: Some distributions include a fallback initramfs (e.g.,
initramfs-linux-fallback.img). Boot it from GRUB advanced options. - Boot with nomodeset: Add
nomodesetto kernel parameters to rule out graphics driver issues. - Manual root mount: At GRUB, press 'e' to edit boot parameters and manually set
root=/dev/sdXY(or UUID) andro. - Reinstall kernel: If the kernel image is missing or broken, reinstall the kernel package via live environment.
Prevention
- Always keep a live USB handy for recovery.
- After kernel or driver updates, verify that initramfs rebuilds successfully.
- Use UUIDs in
/etc/fstaband GRUB instead of device names (e.g.,/dev/sda1) to avoid boot failures due to device reordering. - Regularly backup GRUB configuration and critical boot files.
- Test boot after each major system update before rebooting production systems.
Was this solution helpful?