Hyper-V Guests: Compile Linux Kernel 2.6.32 on Debian
In this post I will be detailing the steps needed to compile a new kernel in Debian Linux 5. 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 Debian as a supported guest operating system.
BEFORE YOU BEGIN
- Install Debian 5 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 fakeroot
DOWNLOAD KERNEL SOURCE
# cd /usr/src
# wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-188.8.131.52.tar.bz2
PREPARE KERNEL SOURCE
# bzip2 -d linux-184.108.40.206.tar.bz2
# tar xf linux-220.127.116.11.tar
# cd linux-18.104.22.168
BUILD KERNEL CONFIGURATION
# make menuconfig
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
# cd ../
# ls -l
# dpkg -i linux-image-22.214.171.124_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 126.96.36.199
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 amd6188.8.131.52 (stock)||85MB/s, 89MB/s, 79MB/s||93MB/s, 88MB/s, 100MB/s|
|Ubuntu 9.10 amd64 184.108.40.206||388MB/s, 345MB/s, 377MB/s||393MB/s, 417MB/s, 389MB/s|
|Debian 5 amd6220.127.116.11 (stock)||81MB/s, 67MB/s, 67MB/s||89MB/s, 92MB/s, 93MB/s|
|Debian 5 amd618.104.22.168||285MB/s, 119MB/s, 188MB/s||353MB/s, 207MB/s, 181MB/s|
- 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.