Tuesday, February 09, 2010

IT From All Angles

Minimize
May 12

Written by: Matthew.Mattoon
Tuesday, May 12, 2009 

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.

Tags:

37 comment(s) so far...

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Hi,

Great article! I'm using Ubuntu Server 9.04 amd64 with a few hard drives added to a SCSI controller in Hyper-V. Where would those HDDs be located at under Ubuntu? I looked in /dev but to no avail. I can confirm that all the drivers are loaded successfully using lsmod even though I'm seeing errors during initial boot time (I used the updated '/etc/initramfs-tools/modules' method to load the drivers at startup).

Thanx

By Benjamin on   Saturday, May 30, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Nevermind, I found them under /proc/scsi/scsi ! But I still get errors during boot up...

By Benjamin on   Sunday, May 31, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Hi Benjamin,

Sorry it took me a few days to respond. You commented while I was en route to the UK and I haven't been online until now. Anyways. What errors are you getting on boot up? Lets take this offline and we can post back a resolution to this comment thread if it pertains to this article. You can find an email form on the main page in the "About Me" section.

-matt

By Matthew Mattoon on   Monday, June 01, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

For current Ubuntu Server 8.04.2, kernel version is 2.6.24-23-server today on June 05.
So, what is a solution? That Microsoft provides Integration Services for Ubuntu on Hyper-V?

By Timur on   Friday, June 05, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Excellent article. Is it working with both Hyper-V v1 and v2?

By Tamás Lepenye on   Friday, June 05, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Timur,

Microsoft does not support Ubuntu with the Linux Integration Components, so I doubt that they will release a version of the ICs specifically for Ubuntu. Now that said my article addresses exactly what you are asking (how do I get ubuntu server 8.04.2 working with the integration components). As I addressed in the article you have to have kernel version 2.6.19 or lower in order to use this work around, so you have to downgrade the kernel.

Tamas,

I have not verified the instructions on Hyper-V v2 with the Linux Integration Components v2, however the ICs have not changed significantly and should work the same.

-matt

By Matthew Mattoon on   Sunday, June 07, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Wanted to say thank you for the thorough documentation - I was loathe to have to use a redhat-based OS as I'm most comfortable in Debian, so having a "real" Debian 5.0 VM on my Hyper-V servers is quite nice. I'm working on getting this to work with the newer kernels, although it is indeed quite a pain. Something's changed between 2.6.19 and 2.6.20 (perhaps KVM, I'm not sure) that seems to cause all sorts of troubles building the modules and getting them to actually work properly.

By cluberti on   Wednesday, June 17, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Hi Cluberti,Glad to hear my article has helped you. The change is in how many arguments that INIT_WORK will accept (2.6.20+ will only accept 2 - IC script invokes 3 - many drivers have had this problem. I think it was a webcam driver discussion that led me to discover this), a friend of mine who is more familiar with this type of code took a look at it and it is really just a code thing in the IC scripts. I personally did not want to modify the code (for legal, support, and distribution reasons) so I instead decided to write up this in a way that anyone (even those not terribly well versed in Linux) could implement this in a functional way... Additionally I have also provided my findings to Microsoft with some recommendations, however while I am sure that it will be addressed I am not sure in what way or even how soon we can expect to see something.If running other versions of Linux with the Integration Components is important to you please ensure that you provide this feedback to Microsoft. They want to provide this support, but it is hard to provide a business case when they are not even sure there is a use-case.-matt

By Matthew.Mattoon on   Thursday, June 18, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Hi,

Great post!

I did some benchmark tests on kernel 2.6.18-6 with LinuxIC and newest kernel 2.6.28-11.37
With LinuxIC installed I got 100% better disk performance, but CPU and memory speed is better on newer kernel.

Tests are taken on Ubuntu 9.04 server.
Testing server was Dual Xeon 5405, HW Raid10, 8GB ram.
Tested VM got "4 cpu cores" and 2gb ram.

Benchmark test is "UnixBench v4.1.0 - WHT Variant" (www.webhostingtalk.com/showthread.php?t=308055)

Results are :
2.6.18-6 with LinuxIC - score 110
2.6.28-11.37 - score 172.8

I'm trying to install LinuxIC with new kernel. I will post results :)

By Ivan Cacija on   Monday, June 22, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

FYI - I have run into an issue when using the Integration Components with Debian 5 (i386) with an iSCSI LUN. I will post an update when I run some more tests. If anyone out there has additional information on a similar issue please let me know via my email form.

-matt

By Matthew Mattoon on   Wednesday, July 01, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Great article. I am conducting a research project at my univercity (performance rating of different virtualization solutions) at the moment and I honestly doubt that I´d have been able to activate ICs without your article. For this, you have my deepest thanks. ;)

Do you have any additional info as to what changed after 2.6.19 kernel, that caused the compiler to fail?

By Tolwyn on   Friday, July 03, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Amazing article. The answer to many fruitless sleepless nights on google.
I have a question if I may - at the end of step 2, the prompt displays:

sh: cannot create drvinstall.err: Read-only file system
grep: drvinstall.err: No such file or directory
*** The drivers have been installed successfully. ***

I assumed that the drivers HAD been installed successfully. I skipped the error check and ran
# modprobe vmbus

to which I was prompted:
FATAL: Module vmbus not found.

Im guessing the answer is in making the file system NOT read-only... any wisdom you could zip my way...?

Many thanks
S

By Stuart on   Saturday, July 11, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

UPDATE - I made file system read/write using:
# mount -o remount,rw /dev/hda2 /

(tip thanks to www.linuxquestions.org/questions/showthread.php?p=955297#post955297)

re-ran setup and it worked as you said.

By Stuart on   Saturday, July 11, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

This article was a lifesaver.

But now I'm having the problem that I can no longer access my cd-rom drive when I boot into the older kernel. ie. /dev/scd0 just does not show up. If I boot back into the newer kernel, then I see it again, but it requires this weird rebooting every time I need to access a cdrom.

Has anyone else run into this?

Any ideas what to do about it?

-Nate

By Nate Kushman on   Wednesday, August 19, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Nice article. Only minor issue issues I'm having is the synthetic network adapter isn't showing up in the network manager... any clues on getting it to show up? I'm running Ubunti 9.04.

Thanks!

By Thai on   Friday, August 28, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

The new linux integration components (v2) are released. They have built-in support kernel 2.6.27 (the mod_init() params fixed), so they should compile on other kernels too. However you need to be a bit handy in modifying the sources for them to build & run on debian. It isn't too hard however.

Good luck

By Frederic Kinnaer on   Thursday, September 10, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

And, don't forget IC's are now built in kernel and expected to be released with kernel 2.6.32 ;) Can't wait!

By Frederic Kinnaer on   Thursday, September 10, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

How do i count the kernels (step 1) ?

By gjelsvik on   Wednesday, September 23, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Frederic,

The v2 LIC have not been "released" yet. They are currently in RC2. I have been testing with them on other kernels and they DO NOT work on other kernels. They still only work on < 2.6.19 or on 2.6.27. I have been working to modify the source in such a way as to allow them to be installed more intelligently (detect distribution and kernel version and test for compatibility) as well as make the installer more generalized (Currently the code looks for specific kernel versions as a method of detecting distribution - in other words if you have 2.6.27 then it assumes you are on a SUSE box and modifies configs as if it were SUSE). Watch for posts if you are interested in this... Also if anyone thinks they could be of assistance in this modification please email me using the mail form on this site.

@gjelsvik

In the menu.lst file there is a section for each installed kernel, find each grouping and count them starting with 0.

-matt

By Matthew Mattoon on   Wednesday, September 23, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

How do i count the kernels (step 1) ?

By gjelsvik on   Wednesday, September 23, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

How do i count the kernels (step 1) ?

By gjelsvik on   Wednesday, September 23, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

hmm seems like my browser double postes when i refreshed the page, sorry.

Thanks for a fast answer!
Im trying to get my virtual ubuntu machine to be able to use a pass through disk in hyperv. The drive doesnt show up in 'fdisk -l' Its connected to the virtual SCSI controller. Do you know if this is driver related, or do i need the IC?

By gjelsvik on   Wednesday, September 23, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Matthew Mattoon... /bow
Splendid article, thank you. I was looking to make IC work on my Ubuntu for very long time now. And those finally do work. Unfortunately, I got same bug with CD-ROM device, as -Nate - my /dev/scd0 has gone missing, but that's not a problem to me as I'm hardly ever using this device on my Ubuntu VM.

By Alex on   Friday, October 09, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

These work fine for me in 2_6_28-11 and -15 (server).

First you have to get the source and the headers for your kernel version. I had to manually make the symlink for 2_6_28-15-server for the build folder for some reason.

Anyway then go into the folder you put the integration components in and do:
find ./* -type f -exec sed -i 's/2_6_27/2_6_28/g' {} \;

...this replaces all instances of 2_6_27 with 2_6_28 in the source code so it doesn't complain about INIT_WORK and the like.

...then run the setup.pl. Note that if you upgrade your kernel you have to redo these steps.

By Adam Brand on   Saturday, October 17, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

I tried to do what Adam said but it gives me an error. I modified the Makefile directly but still get the INIT_WORK undeclared. I have a 2.6.28 kernel. Does it not work with this version? Can I go back to a 2.6.27 kernel without issue? I have XUbuntu.

Thanks,
Brian

By Brian Armstrong on   Tuesday, October 27, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Brian, you must use the Linux Integration Components version 2 (Linux Integration Components for Windows Server 2008 Hyper-V R2)

www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c299d675-bb9f-41cf-b5eb-74d0595ccc5c

By Matthieu on   Monday, November 02, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

This no longer works using ubuntu server 9.10, as it now uses grub2 - so you don't edit menu.lst in the same way, and setup.pl looks for /boot/grub/menu.lst which no longer exists.

Is there any way around this?

By Atan on   Saturday, November 07, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Atan,

I did not test this on 9.10 (as it was still pre-release when I did this article) the goal of these steps is to provide you with steps that give you a stable enough system that it can be run in production without worries.

-matt

By Matthew Mattoon on   Wednesday, November 11, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Excellent article!!!!!! Works like a dream. Cant wait for 2.6.32 to be out in the meantime this really helps me to run my Ubuntu machine on Hyper-V. Very much appreciated. THANKS A BUNCH !!!!!!

By O'Neil Dayes on   Thursday, November 26, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Just like Atan, I'm interested to install Ubuntu 9.10 on a Hyper-V. It's a pity that it doesn't work out-of-the-box

By imce on   Monday, November 30, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Hi imce,

I am afraid your information is not entirely correct. Ubuntu 9.10 does work on Hyper-V. You will need to use emulated network adapters as opposed to the Synthetic. Atan was referring to my instructions for installing the Linux Integration Components working with 9.10 (which they do not, since Grub2 is now used).

By Matthew Mattoon on   Monday, November 30, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Hi all!
Great artical

I have allready installed new kernel 2.6.32.6 to ubuntu server 9.10. Kernel from Lucid...
In documentation said that hyper-v drivers integrated... how can i enable them?

p.s. sorry for my english...

By Vladimir Ganzha on   Sunday, December 06, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

I'v found it under /kernel/drivers/staging/hv/
hv_vmbus
hv_blkvsc
hv_netvsc
hv_storvsc

testing in progress

By Vladimir Ganzha on   Sunday, December 06, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

What command did you use to enable this?

Sorry new to linux

By Ray on   Thursday, December 24, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Just to let you all know, I managed to set v2 up on a 2.6.28 kernel (ubuntu server 9.10) by adding a
#define KERNEL_2_6_27
to the all the (offending) .c files from the linux integration components cd image.
Hackish and spits out some errors at boot, but everything seems to be working.

-Y

By Yuriy on   Thursday, December 24, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

What command did you use to enable this?

Sorry new to linux

By Ray on   Thursday, December 24, 2009

Re: Hyper-V Guests: Linux Integration Components Ubuntu and Debian

Great walkthrough! I'm a Windows admin trying to setup Ubuntu for the first time, so this was a life saver!

It didn't work with Ubuntu Server 9.10, at least not in my attempts. The install and Legacy Network Adapter works but installing the Integration Components didn't. Reverting back to version 2.6.18-6 didn't work.

But, I grabbed the 8.04 Server version and it worked like a charm. I had to stumble through mounting the cdrom drive and I didn't understand that "(count the number of the kernels starting with 0 - in my case the installed kernel is number 2 - For Debian it was 4)" meant to reboot and watch the boot choices to get the count. Apart from that everything worked perfectly and was easy to follow for a non-Linux guy. Thanks!

By Scott Forsyth on   Saturday, January 30, 2010

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 

Search IT From All Angles Blog

Minimize