Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Hyper-V Guests: Linux Integration Components Ubuntu and Debian

In this article I am documenting the process for installing the Hyper-V Integration Components within a Ubuntu or Debian VM. I am specifically writing this for Ubuntu 8.04.2 and Debian 5, however I have additionally confirmed that this process works on both Ubuntu 8.10 and Ubuntu 9.04. My environment consists of x64 VMs, I have not taken the time to test this process for x86 VMs, however it should hold true, as long as you update the package names to reflect the appropriate architecture.

In my testing I have found that the current versions (v1 and v2) do not work with linux kernels 2.6.20 or newer, which means in order to use the ICs you will need to have 2.6.19 or older. For this article I wanted to make sure this process was simple enough that if you do not fully understand what I am doing, you can still follow along, and hopefully learn something. Because of this focus on simplicity I have decided to use the linux kernel 2.6.18-6, which I was able to find in some official apt repositories. If you are familar with manually installing a kernel image then feel free to install the 2.6.19 kernel image. However I will not be covering that in this article.

While reading the Hyper-V Integration Components readme they talk about implementing the Xen kernel (x2v) this is not necessary, and really is kind of a hinderance for a lot of production environments. I will not be installing this as part of this article.

Now before we get started you need to deploy a new VM with Ubuntu or Debian installed. Please do not attempt to follow these instructions on a production machine, do it in test until you are comfortable with the process, then do it in prod.

STEP 1 – Install the New Old Kernel and Prerequisites
Elevate permissions to root (on Debian you will need to su -)
$ sudo -s
Open the /etc/apt/sources.list
# nano /etc/apt/sources.list
Add the following at the end

## Repositories which contain older versions of the linux kernel (needed for Hyper-V Linux IC)
deb http://ftp.us.debian.org/debian etch main
deb http://security.debian.org/debian-security etch/updates main

Update your package list (You will get GPG errors/warnings on Ubuntu since the keys are not loaded for this debian repository)
# apt-get update
Install the kernel, headers, and build-essential (needed to compile Linux IC later)
# apt-get install linux-image-2.6.18-6-amd64 linux-headers-2.6.18-6-amd64 build-essential
Comment out the repositories we added earlier
# nano /etc/apt/sources.list

## Repositories which contain older versions of the linux kernel (needed for Hyper-V Linux IC)
# deb http://ftp.us.debian.org/debian etch main
# deb http://security.debian.org/debian-security etch/updates main

Change the default boot kernel (count the number of the kernels starting with 0 – in my case the installed kernel is number 2 – For Debian it was 4)
# nano /boot/grub/menu.lst

default 2

Reboot
# reboot

STEP 2 – Install Linux Integration Components
Elevate permissions to root (on Debian you will need to su -)
$ sudo -s
Confirm boot to correct kernel.
# uname -a
Prestage Integration Components files
# mkdir /opt/linux_ic
Copy files from cd (Debian had it at /media/cdrom0)
# cp -R /media/CDROM/* /opt/linux_ic/
# cd /opt/linux_ic
Execute installation script (this willl result in an error while “installing various udev rules and scripts”)
# ./setup.pl drivers
View the drvinstall.err to confirm that the error was the expected error.
# cat drvinstall.err

Building modules, stage 2.
/opt/linux_ic/drivers/dist/blkvsc/blkvsc_drv.c: In function ‘blkvsc_ioctl’;
/opt/linux_ic/drivers/dist/blkvsc/blkvsc_drv.c:1447: warning: unused variable ‘blkdev’
Building modules, stage 2.
Building modules, stage 2.
Building modules, stage 2.
make: udevcontrol: Command not found
make: *** [install] Error 127

Now this error means that the modules have been created, however there was an issue creating the initrd, so the modules will not be loaded at startup. We will need to manually do this.

STEP 3 – Manually Load Modules for Verification
Load modules with modprobe
# modprobe vmbus
# modprobe netvsc
# modprobe storvsc
# modprobe blkvsc

View loaded modules with lsmod (if this outputs the 4 modules plus the scsi_mod module then the modules are all installed and working)
# lsmod | grep vsc

STEP 4 – Configure Modules to be Loaded at Startup
Open /etc/modules for editing
# nano /etc/modules
Add the following to the end

## Modules needed for Hyper-V Synthetic Devices
netvsc
blkvsc
storvsc

Shutdown the VM and reconfigure the Hyper-V Hardware to remove the Legacy Network Adapter and add the Network Adapter (I personally like to use the same MAC Address).
# shutdown -h now
Power it back up and confirm modules have loaded.
$ lsmod | grep vsc
$ ifconfig -a

Elevate permissions to root (on Debian you will need to su -)
$ sudo -s
Edit /etc/network/interfaces to allow the new interface to start automatically
# nano /etc/network/interfaces
Add the following lines (In Debian I modified the existing entries for eth0 to show seth0 and changed allow-hotplug to auto – when I did not change the allow hotplug to auto it did not automatically use DHCP)

auto seth0
iface seth0 inet dhcp

Restart Networking
# /etc/init.d/networking restart

STEP 4 – Configure Modules to be Loaded at Startup (updated 5/20/2009)
Open /etc/initramfs-tools/modules for editing
# nano /etc/initramfs-tools/modules
Add the following to the end

netvsc
blkvsc
storvsc

Rebuild the initrd image
# update-initramfs -u
Edit /etc/network/interfaces to allow the new interface to start automatically
# nano /etc/network/interfaces
Add the following lines (In Debian I modified the existing entries for eth0 to show seth0 and changed allow-hotplug to auto – when I did not change the allow hotplug to auto it did not automatically use DHCP)

auto seth0
iface seth0 inet dhcp

Shutdown the VM and reconfigure the Hyper-V Hardware to remove the Legacy Network Adapter and add the Network Adapter (I personally like to use the same MAC Address).
# shutdown -h now
Power it back up and confirm modules have loaded.
$ lsmod | grep vsc
$ ifconfig -a

Well there you have it, you now have successfully installed the Linux Integration Components.

UPDATE I (5/20/2009)
When loading storage modules with /etc/modules you will receive some errors in your initial boot screens. These do not affect the loading of the modules, however if you use the below alternative to step 4 then the modules are loaded into the initrd meaning they start with the kernel which eliminates this error. Additionally I moved the network reconfig to prior to the shutdown, to eliminate the need for the networking restart. I have tested this method on Ubuntu and Debian as previously documented.