Sep 15

Fixing the infamous "kernel panic: VFS: Unable to mount root fs" problem.

Tue, 09/15/2009 - 11:08 — peter

The Problem (or how I broke it)

So here I am in this cool conference waiting for the sessions to start while doing some work and I decide play a bit with my kubuntu laptop... Maybe it was bootchart, maybe it was insserv, I don't know... what I do know is that after a reboot I got a kernel panic... you know, when the "scroll lock" and "caps lock" lights keep flashing at you in mockery?

The Context

Although there are many things that can cause that error, I was fairly certain that my case had to do with the initrd file. UUID's checked out fine, menu.1st was fine, everything else was OK. Thing is... this is a fairly fresh install and I only had the 1 kernel left on my laptop AND I didn't have a CD/DVD drive readily available...

The Solution

What I did have, however, was a thumb drive and a dell mini 9. I downloaded the kubuntu iso, used unetbootin (installed with sudo apt-get install unetbootin) to put that iso on the thumb drive and booted my laptop from the usb stick.

Now what? To rebuild initrd, I had to mount the root and boot partitions in my HDD from the live CD, chroot to the mounted root and rebuild the initd file, like so: (note that my boot was on /dev/sda3 and my root was on /dev/sda5 and your particular configuration may as well be different)

sudo su -
mkdir /mnt/root
mkdir /mnt/root/boot
mount /dev/sda5 /mnt/root
mount /dev/sda3 /mnt/root/boot
chroot /mnt/root /bin/bash
mount -t proc /proc /proc
update-initramfs -u

Then reboot and voila! System works again.

Easy Peasy!
-PCP