DEV Community

Dmitry Romanoff
Dmitry Romanoff

Posted on

Fixing the "Kernel Panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)" Error After Upgrading Ubuntu

Upgrading Ubuntu to a new version can be a smooth experience, but occasionally, issues arise that leave us scratching our heads. One common problem that users face after an upgrade is encountering the dreaded Kernel Panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) error. This error often occurs after rebooting into the newly upgraded system, preventing the system from booting properly.

But don’t worry, this issue is often fixable with a few simple steps. In this article, we’ll explain what causes the issue and how to resolve it.

Root Cause: Missing initramfs

The root cause of the Kernel Panic is that the initramfs (initial RAM file system) for the newly installed kernel version is missing. When you upgrade Ubuntu, the kernel gets upgraded as well, but if the initramfs doesn’t get generated for the new kernel, the system fails to boot. The initramfs contains necessary files and modules that the system needs to mount the root filesystem and continue booting. Without it, the kernel can't proceed, and you’ll see the panic message.

Solution: Rebuild initramfs and Update GRUB

The solution involves regenerating the initramfs for the kernel in question and updating the GRUB bootloader.

Here are the steps to resolve the issue:

  1. Access the GRUB menu

    After the kernel panic occurs, you will need to reboot your system. On restart, press the Shift key (or Esc, depending on your system) to access the GRUB menu. Once you're in the GRUB menu, you should see an option for Advanced options for Ubuntu.

  2. Select Another Kernel

    In the Advanced options for Ubuntu section, you'll see a list of available kernels. Select an older kernel version that you know worked before the upgrade (usually the previous version of Ubuntu).

  3. Boot into the Older Kernel

    After selecting the older kernel, press Enter to boot into it.

  4. Open the Terminal

    Once you’ve successfully booted into the older kernel, open a terminal window.

  5. Regenerate initramfs for the New Kernel

    To fix the issue, you need to regenerate the initramfs for the new kernel version. Run the following command in the terminal:

   sudo update-initramfs -u -k <version>
Enter fullscreen mode Exit fullscreen mode

Replace <version> with the actual kernel version string for the kernel that you were unable to boot into. For example, it might look something like 4.15.0-36-generic.

You can find the kernel version by running uname -r if needed.

  1. Update GRUB Once the initramfs has been successfully generated, update the GRUB bootloader by running:
   sudo update-grub
Enter fullscreen mode Exit fullscreen mode

This command ensures that GRUB recognizes the updated kernel and its corresponding initramfs.

  1. Reboot After updating GRUB, reboot your system by running:
   sudo reboot
Enter fullscreen mode Exit fullscreen mode

This time, the system should boot into the new kernel without the kernel panic error.

Conclusion

If you’re encountering the Kernel Panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) error after upgrading Ubuntu, it's likely due to a missing initramfs for the new kernel. By following the steps above to regenerate the initramfs and update GRUB, you should be able to resolve the issue and get your system back to normal.

Upgrades can sometimes cause unexpected problems, but with a bit of troubleshooting, you can usually resolve them quickly.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

👋 Kindness is contagious

If you found this post helpful, please leave a ❤️ or a friendly comment below!

Okay