FAN Hyper-V Kernel Panic Fix for switchroot: mount failed

Fully Automated Nagios 2.4 is based on CentOS 5.9, so these instructions also apply to any upgraded or new installation of CentOS 5.9 on Hyper-V. CentOS 5.9 adds the Linux IC (integration components) for Hyper-V as part of its install process. However, this can cause a kernel panic crash when booting CentOS 5.9 Hyper-V VMs. This includes pre-built ISOs that include CentOS 5.9, such as the latest release of FAN (Fully Automated Nagios), or existing CentOS releases that were upgraded to CentOS 5.9.
This is part of the error message that is displayed because the proper Hyper-V virtual disk driver is not being loaded correctly:

switchroot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!

Fixing a brand new installation of a CentOS 5.9 release, including FAN 2.4:

Add the original ISO you used for the installation, such as FAN-2.4 or CentOS 5.9, as a DVD drive in Hyper-V.
Boot the Hyper-V system, and at the boot prompt, type “linux rescue”.
Follow the prompts to mount the existing CentOS installation, and get to the shell.
Run the following command to make the installed system the root (/) environment:

chroot /mnt/sysimage

View the contents of the /etc/grub.conf file to note the exact version of the installed kernel, which will be used in the next command:

cat /etc/grub.conf

Run the following command, replacing “VERSION” with the version you noted from the output of the grub.conf file:

mkinitrd /boot/initrd-VERSION.el5.img VERSION.el5 --preload hv_storvsc --preload hv_vmbus --preload hv_utils -f

For example, if the grub.conf file noted that the kernel was “/vmlinux-2.6.18-348.1.1.el5,” the version number is 2.6.18-348.1.1. The mkinitrd command would then be the following:

mkinitrd /boot/initrd-2.6.18-348.1.1.el5.img 2.6.18-348.1.1.el5 --preload hv_storvsc --preload hv_vmbus --preload hv_utils -f

Type “exit” twice to reboot, and your system should boot normally.
Update 8/1/2013: As noted by Peter in the comments, the above string has el5 in it – note that it’s an “L” and not a “1” before the 5.

Fixing an upgraded installation of CentOS 5.9, including previous versions of FAN that were upgraded:

To fix an existing installation that you upgraded, when booting, select the previous kernel that worked. Once booted, run the following command to find the exact version number of the new kernel:

cat /etc/grub.conf

Take note of the newest kernel version number.
Next, run the following command, substituting the version number where noted:

mkinitrd /boot/initrd-VERSION.el5.img VERSION.el5 --preload hv_storvsc --preload hv_vmbus --preload hv_utils -f

For example, if /etc/grub.conf noted that the kernel was “/vmlinux-2.6.18-348.4.1.el5” the version is 2.6.18-348.4.1, so the mkinitrd command would be the following:

mkinitrd /boot/initrd-2.6.18-348.4.1.el5.img 2.6.18-348.4.1.el5 --preload hv_storvsc --preload hv_vmbus --preload hv_utils -f

Reboot your system, and you should now be able to successfully boot from the newest kernel.
Update 8/1/2013: As noted by Peter in the comments, the above string has el5 in it – note that it’s an “L” and not a “1” before the 5.

Full error messages:

These are the full error messages when booting:
Scanning logical volumes
Reading all physical volumes. This may take a while...
No volume groups found
Activating logical volumes
Volume group "VolGroup00" not found
Trying to resume from /dev/VolGroup00/LogVol01
Unable to access resume device (/dev/VolGroup00/LogVol01)
Creating root device.
Mounting root filessystem.
mount: could not find filesystem '/dev/root'
Setting up other filessystems.
Setting up new root fs
setuproot: moving /dev failed: No such file or directory
no fstab.sys, mounting internal defaults
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
Switching to new root and running init.
unmounting old /dev
unmounting old /proc
unmounting old /sys
switchroot: mount failed: No such file or directory Kernel panic - not syncing: Attempted to kill init!

More reading:

http://www.centos.org/modules/newbb/viewtopic.php?topic_id=41048&viewmode=flat&order=ASC&start=0

28 Comments

  1. Thank you very much.
    just to make it work on a VM to a Hyper-V in 2012, I had to:
    mkinitrd /boot/initrd-2.6.18-348.4.1.el5.img 2.6.18-348.4.1.el5 –preload hv_storvsc –preload hv_vmbus –preload hv_utils –preload hv_netvsc –preload hid-hyperv –preload hid-base-hv -f

    • Thank you to Steve for the original post and to anonyme for the expansion of it. Anonyme nailed it for Server 2012 Hyper-v installation.

    • What is the content of your grub.conf file? You need to get the exact kernel version on your computer.
      Run the following command:
      cat /etc/grub.conf
      There should be a listing of “kernel” followed by something like “/vmlinux-2.6.18-348.1.1.el5″ – the part after vmlinux- is the version that you should be putting into the mkinitrd command.

    • I had the same problem. I thought the last part of the version string was “E15”, not “EL5”.
      Thanks for the great writeup! Saved my bacon!

  2. [root@h11-53 ~]# mkinitrd /boot/initrd-2.6.18-128.el5.img 2.6.18-128.el5 –preload hv_storvsc –preload hv_vmbus –preload hv_utils -f
    No module hv_storvsc found for kernel 2.6.18-128.el5, aborting.
    it said no moduel hv_storvcs found …

  3. Thanks it worked. Do you know how I could automatically load these modules into an preinstallation ISO disk.
    We use a kickstart to unattend the installation process of the OS. Can somebody give me a pointer where I could configure to load these modules once the installation is done??
    Regards

  4. Just install FAN version 2.2 instead of newest 2.4. The 2.4 version is using CentOS version which is missing some vital Hyper-V drivers.

  5. Wow, that makes life easier!
    5nine FREE Converter leaves Centos VM unusable with error
    “Volume group “VolGroup00” not found during boot
    The above procedure makes it all working again
    sebus

    • I think it may be lost when updating. Since you’re running this on Hyper-V, I recommend taking a virtual machine snapshot before you make the update to the kernel. That way if you have any issues, you can revert back to a working system. If you do an update and have issues, please report back! Thanks!

  6. Thanks Steve! Your method for booting to the Linux Rescue console using an install disk and making an ram disk that is Hyper-V friendly worked.
    I included a link to this site in the Microsoft TechNet Windows Server 2012 Hyper-V forum, in the answer I posted to the question I also posted, with credit to you.
    I hope that’s acceptable.
    Thanks again for your help. Yours is the most clear explanation that I’ve found on how to deal with Kernel Panic, especially after migrating a CentOS server to Hyper-V, when booting to all available kernels results in Kernel Panic.

  7. Hello,
    I have the same Problem with the Kernel Panic on a HyperV 2008R2 .
    But my Problem is, that I do this, like explained it in –> FIX for a BRAND NEW Installation of CentOS 5.9
    I boot in the linux rescue MODE and looking with ” cat /etc/grub.conf ” – my Kernel is the –> initrd-2.6.18-348.1.1.el5.img
    i try in the next STEP –>
    mkinitrd /boot/initrd-2.6.18-348.1.1.el5.img 2.6.18-348.1.1.el5 –preload hv_storvsc –preload hv_vmbus –preload hv_utils -f
    BUT they always say –> No modules hv_storevsc found for kernel 2.6.18-348.1.1.el5, aborting.
    What can i do now??
    .
    .

1 Trackback / Pingback

  1. Adventures in Nagios FAN | DataGuys

Leave a Reply

Your email address will not be published.


*