Nate Silva

Apr 10 2011

How to upgrade CentOS Linux running under Hyper-V

When CentOS Linux, running under Hyper-V, is upgraded to a new kernel, it will probably fail to reboot. Open Hyper-V Manager and look at the CentOS server’s screen. Most likely you will see the following error:

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

Cause

The error is caused by the Microsoft Hyper-V Linux Integration Components not loading properly under the new kernel.

Solution

  1. From the Hyper-V Manager, reboot the server. At the moment when it says “Booting CentOS in 3…2…1…,” press any key. You’ll see several kernels listed, including the newest one and the previous one.
    • Make a note of the full, exact version number of the newest kernel.
    • Select the previous kernel and press Enter. It should boot successfully under the old kernel.
  2. Log in as root.
  3. Use Hyper-V Manager to attach the Microsoft Linux Integration Components CD (LinuxIC v21.iso, available from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=eee39325-898b-4522-9b4c-f4b5b9b64551).
  4. Mount and copy it to the Linux server.
    1. mkdir -p /mnt/cdrom
    2. mount /dev/cdrom /mnt/cdrom
    3. cp -rp /mnt/cdrom /opt/linux_ic
    4. umount /mnt/cdrom
  5. By default the Linux IC will build for the currently-running kernel. We want to build for the newer kernel instead. Make this happen:
    1. cd /opt/linux_ic
    2. [substitute the new kernel’s version in the following command]
      grep -ilR uname * | xargs sed -i 's/uname \-r/echo "2.6.18-238.5.1.el5"/g'
    3. make && make install
    4. reboot

Your server should now boot under the new kernel.

(Found in this message thread on the CentOS user forums.)

Page 1 of 1