Sunday, 19 March 2017

Kernel Panic - Not syncing : VFS: unable to mount root fs on unknown-block (0,0)

Just a quick brain dump after I recovered my home server running centos 7. I had to recover it because it was failing to boot after I did  
yum update
I have to admit, it was partially my fault it failed. I was running several python scripts trying to brute-force something for one of the CTF (Capture The Flag) I'm doing at the moment :)
Yum froze when it tried to update python... I couldn't see any other option than kill the process. After restart... I was getting sad message:
Kernel Panic - Not syncing : VFS: unable to mount root fs on unknown-block (0,0)

I was able to boot using previous kernels and recovery mode so a quick google search gave me a command to remove invalid kernel (all commands have to be run as root or with sudo):
First find out the exact version of the kernel you want to remove:

yum list kernel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.clouvider.net
 * epel: mirrors.coreix.net
 * extras: mirrors.vooservers.com
 * updates: mirrors.coreix.net
Installed Packages
kernel.x86_64                   3.10.0-327.el7                         @anaconda
kernel.x86_64                   3.10.0-514.2.2.el7                     @updates
kernel.x86_64                   3.10.0-514.6.1.el7                     @updates
kernel.x86_64                   3.10.0-514.10.2.el7                    @updates


Then remove the invalid one:
yum remove kernel-3.10.0-514.10.2.el7



 Run update again (this time without python running in the background ;) )
yum update


Restart to enjoy your new kernel (you do not have to do this immediately but it's good to check rather quickly if everything will work after reboot)
shutdown -r now