Hyper-V : Upgrading kernel on an CentOS guest OS

CentOS works pretty well under Hyper-V once you install the Linux IC from Microsoft. I see significantly improved disk i/o performance, along with network performance. However, there is a glitch with the Microsoft supported solution. There is no official explanation or steps on how to upgrade your CentOS kernel to the latest, after you have he IC installed on a earlier version. If you attempted to upgrade the kernel, you’ll be stuck with a dead system (well, you can manually revert back to the old kernel).

So, I needed to install Asterisk 1.8 on a CentOS guest. I had a pre created template of a CentOS 5.4 system that I’ve been using a while, and started my process on that. After installing the Asterisk repositories, and installing Asterisk 1.8, I did notice that yum had upgraded my Kernel. I knew this would be a problem, so what we need to do is upgrade the Linux IC to run on this new kernel. Unfortunately, running “setup.pl drivers” from the linux IC source doesn’t do much, since it’ll just upgrade the current running kernel, which is not the one that’s been installed.

To upgrade the Linux IC, you need to fake the output of uname with the latest version of the kernel so that the setup and make scripts know what to build on.

What I ended up doing, was writing a simple c program to fake the uname output so that uname would give the names of the newest kernel, not the current one. If you are stuck in this situation, simple make a new file with the following source (change the kernel versions as required), and compile and replace the system uname with our “fake” uname.

#include <stdio.h>

int main(int argc, char* argv[])
{
        if (argc > 1)
        {
                if (strcmp(argv[1], "-r") == 0)
                {
                        printf("2.6.18-194.32.1.el5\n");
                }
                else if (strcmp(argv[1], "-p") == 0)
                {
                        printf("x86_64\n");
                }
                else if (strcmp(argv[1], "-m") == 0)
                {
                        printf("x86_64\n");
                }
        }

        return 0;
}

That’s it. Save it, and compile it with “cc uname.c”. Make a backup of the current uname (in /bin/uname), and then copy this file over to “/bin/uname” and then run setup.pl drivers

 

Done

One Reply to “Hyper-V : Upgrading kernel on an CentOS guest OS”

Leave a Reply

Your email address will not be published. Required fields are marked *

*