Thursday, March 11, 2010

IT From All Angles

Minimize
Dec 18

Written by: Matthew.Mattoon
Friday, December 18, 2009 

In this post I will be detailing the steps needed to compile a new kernel in Ubuntu Linux 9.10.  This particular case we are purpose building a kernel with the drivers necessary for Hyper-V Guests to take advantage of synthetic devices.  Additionally I plan on expanding this series with instructions for manual compiles of other distributions as well as some pre-compiled image based installs.

DISCLAIMER:  These instructions are not provided with any guarantee of support.  Microsoft (company behind Hyper-V) does not acknowledge Ubuntu as a supported guest operating system.  Canonical (company behind Ubuntu) will not support custom compiled kernels.


BEFORE YOU BEGIN

  • Install Ubuntu 9.10 amd64 inside of a Hyper-V VM.
  • My Hyper-V VM was 40GB IDE VHD with 1 Processor, 1GB of RAM, and 1 Emulated Network Adapter (I will later swap for a Synthetic once the kernel is installed) - other configs may work, but have not been tested.
  • If you are on a network which requires a proxy server ensure you export http_proxy before attempting to use apt or wget.

 

INSTALL SOFTWARE PREREQUISITES
# apt-get install build-essential ncurses-dev kernel-package
DOWNLOAD KERNEL SOURCE
# cd /usr/src
# wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.1.tar.bz2
PREPARE KERNEL SOURCE
# bzip2 -d linux-2.6.32.1.tar.bz2
# tar xf linux-2.6.32.1.tar
# cd linux-2.6.32.1
BUILD KERNEL CONFIGURATION
# make menuconfig

menuconfig_loadablemodule menuconfig_loadablemodule_options

Enable loadable module support (enabled by default)

menuconfig_devicedriversmenuconfig_devicedrivers_staging   

menuconfig_devicedrivers_staging_hyperv-disabledmenuconfig_devicedrivers_staging_hyperv-enabled    

Device Drivers > Staging Drivers > Microsoft Hyper-V Client Drivers

COMPILE KERNEL (takes about 1 hour)
# make-kpkg clean
# fakeroot make-kpkg --initrd --revision=hv.custom.1.0 kernel_image
INSTALL KERNEL
# cd ../
# ls -l
# dpkg -i linux-image-2.6.32.1_hv.custom.1.0_amd64.deb
SWITCH CONFIGURATIONS FROM EMULATED TO SYNTHETIC NETWORK ADAPTER
# sed -i 's/eth/seth/g' /etc/network/interfaces
CONFIGURE MODULES TO LOAD AT BOOT
# echo –e “hv_vmbus\nhv_storvsc\nhv_blkvsc\nhv_netvsc” >> /etc/initramfs-tools/modules
# update-initramfs –u –k 2.6.32.1
SHUTDOWN GUEST TO SWAP VIRTUAL HARDWARE 
# init 0 
REPLACE NETWORK ADAPTER AND POWER ON GUEST

In Hyper-V: Copy the MAC address from the Network Adapter (Emulated) to be used on the newly created Network Adapter.

VERIFY CORRECT KERNEL
# uname -a
VERIFY MODULES LOADED
# lsmod | grep hv
VERIFY NETWORK CONFIGURATION
# ifconfig | grep seth -C 1
VERIFY STORAGE PERFORMANCE
# dd if=/dev/zero of=/root/testfile bs=4M count=1000 
 

 

 

Windows 2008 Hyper-V with SP2

Windows 2008 R2 Hyper-V

Ubuntu 9.10 amd64

2.6.31.14 (stock)

85MB/s, 89MB/s, 79MB/s

93MB/s, 88MB/s, 100MB/s

Ubuntu 9.10 amd64 2.6.32.1

388MB/s, 345MB/s, 377MB/s

393MB/s, 417MB/s, 389MB/s

Debian 5 amd64

2.6.26.1 (stock)

81MB/s, 67MB/s, 67MB/s

89MB/s, 92MB/s, 93MB/s

Debian 5 amd64

2.6.32.1

285MB/s, 119MB/s, 188MB/s

353MB/s, 207MB/s, 181MB/s

 

 

NOTES

  • If you are not able to boot into the correct kernel you may need to change the default in grub.  Ubuntu 9.10 + uses grub2 which has different files and procedures to update it.  Grub simply update the /boot/grub/menu.lst with the correct number of your kernel as default.  Grub2 update /boot/grub/grub.cfg and update with the correct version of your kernel as default, then execute update-grub to write the change to the boot sector.

Tags:

14 comment(s) so far...

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

I was lazy enough to copy paste commands into terminal window. After I executed
echo –e “hv_vmbus\nhv_storvsc\nhv_blkvsc\nhv_netvsc” >> /etc/initramfs-tools/modules
I got modules looking like:
–e “hv_vmbus\nhv_storvsc\nhv_blkvsc\nhv_netvsc”

Everything went fine but of course I got no hv modules in the end. It took me some time to figure out what went wrong.

By Art Shayderov on   Tuesday, December 22, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

Yes!
I got it!

BTW is your captcha case-sensitive? I missed 2 times. 3rd time is the charm as they say.

By Art Shayderov on   Tuesday, December 22, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

Art,

The command should append the following to /etc/initramfs-tools/modules

hv_vmbus
hv_storvsc
hv_blkvsc
hv_netvsc

Yes my captcha is case sensitive.

-matt

By Matthew Mattoon on   Tuesday, December 22, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

Hi Matt,
I came back here today and when I saw my 2 comments I realized that they look absolutely crazy. I was very emotional at the time and I forgot to thank you. I'm sorry about that and thank you for this post.

Art

By Art Shayderov on   Thursday, December 24, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

Hi Guys,

Does this solve the RDP mouse issue?

If not - is there any way to fix this?

Thanks

By Ray on   Thursday, December 24, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

Ray,

Mouse integration is provided in a separate kernel module which is NOT included in the new kernel. For that you will want to refer to my other article:
blog.allanglesit.com/Blog/tabid/66/EntryId/26/Hyper-V-Guests-Mouse-Integration-on-Linux-VMs.aspx

I have not tested this on the new kernel version so it may or may not work.

-matt

By Matthew Mattoon on   Thursday, December 24, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

Art,

You are very welcome.

-matt

By Matthew Mattoon on   Thursday, December 24, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

Hello,
I really tank Matt for this article!
I´m a Linux beginner and I spend about two days working around this article because I hadn´t enough knowledge and Linux X HyperV its really new! At that moment my guest virtual Linux wasn´t able to accesses internet and to make things easier, I wrote a step-by-step. Please, correct me if I´m wrong in some way!
I installed build-essential and kernel-package from Ubuntu ISO CD using:
#apt-cdrom add
#apt-get install build-essential kernel-package

I couldn´t find and install ncurses-dev package even with Ubuntu 9.1 ISO CD, and to solve it, I downloaded from Ubuntu repository (us.archive.ubuntu.com/ubuntu/pool/main/n/ncurses/ncurses_5.5.orig.tar.gz ) to my PC and recorded it in a .ISO and installed it like this:
First I copied the .gz2 file from .ISO to Linux HD and uncompacted it. After that I executed:
#gunzip ncurses_5.5.orig.tar.gz
#tar –xf ncurses_5.5.orig.tar.gz
#./configure
#make install

Other problem was the Kernel download. I downloaded to my PC and recorded it in a .ISO and installed following the Matt instructions just changing apt-web step to copy from .ISO. After compile and install the new Kernel, I set up the network interface like this:
First I checked the network interface´s name using
#ifconfig –a
The interface´s name was seth0 and to set it up go to etc/network/ directory and:
#Pico interfaces
Insert this lines (if you have a DHCP server at your network):
auto seth0
iface seth0 inet dhcp
(to save change ctrl+o and to exit ctrl+x)
After that reboot, test the network connection using PING and have fun!

Note: First I tried to download and install a kernel already compiled and it didn´t work as Matt sad before.

My next fight will be with NAGIOS! Let´s see if will be easy or hard!

Thanks again Matt and sorry for my poor English!

By Ricardo e Ciro on   Monday, December 28, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

http://blog.allanglesit.com/Blog/tabid/66/EntryId/26/Hyper-V-Guests-Mouse-Integration-on-Linux-VMs.aspx
It dose not solve, drivers writen just for MS linux ICS v1

By Vladimir Ganzha on   Tuesday, December 29, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

and why so complex?

you need just add to repository
deb mirrors.kernel.org/ubuntu lucid main

download last kernel

add to # /etc/initramfs-tools/modules
hv_vmbus
hv_storvsc
hv_blkvsc
hv_netvsc

and run # update-initramfs

that's all you need? and dont't need to compile kernel

i've just checked hv versions between 2.6.32-9.13 from lucid main and 2.6.32.2 from kernel.org
it is edentical, no difference.

Build Description=Version 2.0
Vmbus supported version = 13

By Vladimir Ganzha on   Tuesday, December 29, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

and from deb mirrors.kernel.org/ubuntu lucid main
you can download compiled kernel for ubuntu server, that very important for me

tests in my hardware

Ubuntu 9.10 amd64 2.6.32-9.13 Windows 2008 R2 Hyper-V

hmh@userv:~$ sudo dd if=/dev/zero of=/root/testfile bs=4M count=1000
1000+0 записей считано
1000+0 записей написано
скопировано 4194304000 байт (4,2 GB), 7,95108 c, 528 MB/c
hmh@userv:~$ sudo dd if=/dev/zero of=/root/testfile bs=4M count=1000
1000+0 записей считано
1000+0 записей написано
скопировано 4194304000 байт (4,2 GB), 7,25755 c, 578 MB/c
hmh@userv:~$ sudo dd if=/dev/zero of=/root/testfile bs=4M count=1000
1000+0 записей считано
1000+0 записей написано
скопировано 4194304000 байт (4,2 GB), 7,09555 c, 591 MB/c


By Vladimir Ganzha on   Tuesday, December 29, 2009

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

Everything compiled fine for me. However I see no difference in disk performanace. However the synthetic network card is now working.

Any ideas?

Vladimir Ganzha and "why so complex". Could you provide more detailed instructions on how to install for us newbies. Thanks

By Marty on   Saturday, February 20, 2010

Re: Hyper-V Guests: Compile Linux 2.6.32 on Ubuntu

Hi!

Put up a small script that imitates the official Integration Services installer, but which works with the 2.6.31 (stock) kernel too. No need to recompile the kernel either. DL: sztupy.hu/static/hyper-v-ic-kernel-2.6.31.zip Unzip, run setup.pl and add the modules to auto-load.

By SztupY on   Tuesday, February 23, 2010

.config for linux guest under Hyper-v

A bit unrelated but not so far from original topic:

Does anybody have a clean minimal working .config for a linux guest under Hyper-V 2008 r2?

If I understand correctly, any distro built with such a .config would run under Hyper-V right?

By derek on   Monday, March 01, 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