Wednesday, October 22, 2008

Hosting Redhat Linux Virtual Machine on Hyper-V

These are the steps to setup a RedHat Linux virtual machine on Hyper-V host.
I get this working with the help from other bloggers and my colleague.
This post is an amended version from another blog.

Pre-requisites
Please note that I am using RHEL 5.2 x86_64 and you must have a valid RHN installation number. The RHEL VM is installed as a 64bit machine and please install all packages, meaning install everything. It is also helpful to have a RHN Account so that you can get yum update from rhn.redhat.com. Note that for that “yum” command to work with RedHat Linux, you must be subscribed to their update service so that you can fetch the package, or else you will have to go and find them on your installation DVD/CDs.
You first need to fetch a copy of the ISO image from the zip of the Linux Integration Components.
You will also have to download the kernel source RPM and copy/ftp it to your RHEL VM. You can get this from ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/kernel-2.6.18-92.el5.src.rpm.

Configuring the Virtual Machine
There are steps needed to get this Redhat Linux Virtual Machine working. So please follow this closely. Open Hyper-V Manager and add a Network Adapter, a Legacy Network Adapter and a SCSI Controller with a Hard Drive attached to you RHEL VM. Ensure the Legacy Network Adapter is assigned to the virtual network that contains your physical external network card.

Linux Integration Components RC2
Using the “Media” menu in the Hyper-V “Connect...” window, choose “DVD Drive”, “Insert Disk...” and select the Linux Integration Components ISO image, “LinuxIC-RC2.iso”. Then run
mkdir -p /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cp -rp /mnt/cdrom /opt/linux_ic
umount /mnt/cdrom

Building the Kernel
Let's do a update to ensure that we have the required packages installed. (requires your network is working and have a valid RHN account)
yum install redhat-rpm-config gcc rpm-build make gnupg

Go to the directory where you store the kernel source RPM and install the SRPM with the command:
rpm -ivh kernel-2.6.18-92.el5.src.rpm

You need to edit the spec file in /usr/src/redhat/SPECS/kernel-2.6.spec., so make a backup copy of it first for safety.
Before the “%build” line, insert this line:
patch -p1 -d ../linux-%{kversion}.%{_target_cpu} < /opt/linux_ic/patch/x2v-x64-rhel.patch Next find the line that sets “with_headers” and change it to%define with_headers 0 Find the line that defined “%define with_xen” and change it to%define with_xen 1 and the line containing “%define with_xenonly” and changed to%define with_xenonly 1 You can now build the RPM, which will construct the xen one which is what you need. So cd /usr/src/redhat/SPECS rpmbuild -ba kernel-2.6.spec Be warned, this will take *hours* on a on a virtual machine.

Installing the Kernel
cd /usr/src/redhat/RPMS/x86_64
rpm --force -ivh kernel-xen-2*rpm
rpm --force -Uvh kernel-xen-devel-2*rpm

Build the x2v version of the kernel
cd /opt/linux_ic
perl setup.pl x2v /boot/grub/grub.conf

Reboot, and it should boot your newly built kernel with the X2V shims in place.

Building the Hypervisor, Network and Storage Drivers
The next step is to build the drivers. First, link the "build" link in /lib/modules/ directory to make it point into the kernel source that you have been building from.
Note: Please note that in the preceding commands, the quotes are single backquotes, not apostrophes or anything else.
cd /lib/modules/`uname -r`
ln -nsf /usr/src/kernels/`uname -r`-`arch` build

Build the Drivers
cd /opt/linux_ic
Edit setup.pl and look for the string “kernel-devel”. Change that to “kernel-xen-devel” and save the file.
perl setup.pl drivers

Reboot and you should now have the drivers running.

Building the X Mouse Driver
The last step is to build the mouse driver for use by X. This is very simple, you just need to install a couple of extra packages with
yum install xorg-x11-server-sdk xorg-x11-proto-devel
cd /opt/linux_ic
cd drivers/dist
make inputvsc_install

We are done! You now have the Linux IC installed on your Redhat Linux 5.2 vritual machine.

3 comments:

mytruehost said...

Thumbs up for your post. I would like to conclude that the $1 Hosting servers that web hosting service providers use are extremely powerful and have immense “hard drives” in order to hold the vast amount of information, in digital form, that is required to be able to host multiple websites on the Internet.

Web hosting providers said...

Great post! Thanks for sharing such a awesome information. I must say very good job.
Website hosting

Josi Bunder said...

Best web hosting companies. Reviews, rates, statistics of top hosting companies.
Find best hosting company at www.HostingCompaniesz.com