Upgrading the Kernel
Introduction
The ability to change kernel versions at will can be extremely useful for fighting driver bugs and regressions. The kernel version that ships with LinuxMCE 0710 is 2.6.22-14. At the time of writing the most current kernel version is 2.6.26.5. The .22 kernel is almost a full year old and as such does not support a lot of the newer hardware.
Sometimes, it may be better not to upgrade your whole kernel. If you are only looking to upgrade a single modular driver, then you can often extract the driver files from the newer kernel and compile it against the older kernel. This is usually much quicker, and has the potential to break less things. On the other hand, if you need to upgrade core parts of the kernel, or drivers that are compiled directly into the kernel, you may not have another choice.
This wiki will provide step-by-step instructions to upgrade your kernel. These examples will assume you are upgrading to 2.6.26 from 2.6.22. You may however apply these steps to any 2.6 kernel.
Caveats
A vanilla kernel does not come with several of the modules already present in your LMCE installation. For complete functionality with the new kernel you must compile these non-standard modules against the new kernel source. This is somewhat tedious and may be a little overwhelming for a beginner Linux user.
Upgrade process
Potential problems
All the normal issues of upgrading your kernel apply. As a general safety rule always leave a boot option configured to enable loading of your "known working" kernel.
Steps
The first step is to grab the kernel source and extract it to the /usr/src folder.
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.26.5.tar.bz2 tar -jxvf linux-2.6.26.5.tar.bz rm linux ln -s linux-2.6.26.5 linux
Now lets copy the .config file from our generic 2.6.22 kernel.
cd linux cp /boot/config-2.6.22-14-generic .config
On our first load of menuconfig there will be many warnings displayed about config options present in the .config file that are not valid kernel configs. This is simply due to the removal or renaming of old options. Most of these warnings are insignificant. I would quickly go over this list and verify that any drivers you need haven't been renamed. One option that has been renamed is DVB_CORE_ATTACH. It is now DVB_MEDIA_ATTACH, and you may need it if you use the DVB stack. Also some netfilter matches have been renamed. Simply reselect these from the config menus.
It's also a good idea to go over the kernel and make any optimizations for your particular system.
I opted to change these things:
- Selected exact processor family to enable processor optimization extensions
- Disabled forced preemption (only select this on Core's that are NOT hybrids)
- Build SATA driver into kernel
- Build MD,RAID1,RAID5 modules into kernel
- Build NIC module into kernel
The performance gain from these options is fairly minor, but definitely worth selecting. You may also need to install the ncurses library and development files if you haven't already.
apt-get install libncurses5 libncurses5-dev make menuconfig 2> module_errors
At this point you can start the kernel build process. You may use the standard kernel method or the Debian concurrency method. For simplicity this Wiki will use the standard method.
make make modules_install
You should now build any custom modules you need. Linux MCE (and Ubuntu) come with some non-standard drivers. The key modules to worry about are AppArmor, Asterisk (ztdummy & zaptel), ALSA, nVidia video, ATI video. You are better off downloading the latest nVidia and ATI drivers and installing them using the instructions found in the display drivers wiki. The Gutsy kernel also contains other important video drivers, like ivtv. However most of these drivers are now in the mainstream kernel and are more up-to-date.
I have decided to forgo the AppArmor module. Compiling and running this module would require a complete upgrade of the whole package in addition to manually patching many areas of the kernel. This is entirely too much work for something that is largely useless in a Linux MCE installation.
For the ALSA drivers I opted to upgrade the whole package. I wouldn't bother trying to mix and match different versions. My board has an Intel HDA chip that required the latest version to work properly. Here are the steps for that (Note: You should select your card specifically for the alsa-driver package, using the --with-cards option):
mkdir alsa cd alsa wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.17.tar.bz2 wget ftp://ftp.alsa-project.org/pub/firmware/alsa-firmware-1.0.17.tar.bz2 wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.17a.tar.bz2 wget ftp://ftp.alsa-project.org/pub/plugins/alsa-plugins-1.0.17.tar.bz2 wget ftp://ftp.alsa-project.org/pub/utils/alsa-utils-1.0.17.tar.bz2 wget ftp://ftp.alsa-project.org/pub/oss-lib/alsa-oss-1.0.17.tar.bz2 for fi in *; do tar -jxvf $fi done cd alsa-driver-1.0.17 ./configure --with-cards=hda-intel make make install cd .. for fi in alsa-lib-1.0.17a alsa-plugins-1.0.17 alsa-utils-1.0.17 alsa-oss-1.0.17 alsa-firmware-1.0.17; do cd $fi ./configure make make install cd .. done
For Asterisk, simply download the latest Zaptel sources. Configure, Make, Install.
wget http://downloads.digium.com/pub/zaptel/zaptel-1.4.12.1.tar.gz tar -zxvf zaptel-1.4.12.1.tar.gz cd zaptel-1.4.12.1 ./configure --prefix=/usr make make install
You will also need to recompile LIRC. Note: Some LIRC drivers are not SMP safe and will not compile on SMP kernels. In this case I suggest you pick only the drivers you need. For 2.6.26.5 I had to patch some files in the kernel to get LIRC to compile. The patch is located on the LIRC site. Also only the CVS version will compile.
cd /usr/src/linux wget http://lirc.sourceforge.net/software/snapshots/lirc-bttv-linux-2.6.24.patch patch -p1 < lirc-bttv-linux-2.6.24.patch cd .. cvs -z8 -d:pserver:anonymous@lirc.cvs.sourceforge.net:/cvsroot/lirc co lirc cd lirc-0.8.3 ./configure --prefix=/usr --with-driver=all make make install
Copy your kernel image to your /boot folder. Create a new initramfs image. Update your menu.lst file.
cp arch/yyxx/boot/bzImage /boot/vmlinuz-2.6.26.5 mkinitramfs -o /boot/initrd.img-2.6.26.5 2.6.26.5 nano /boot/grub/menu.lst
Save a list of all currently used modules for future reference. You will use this later to make sure you have all the required modules.
lsmod > ~/module_list-2.6.22.14
Go ahead and reboot. Your new kernel should now load. If your boot fails, simply edit the parameters from the grub menu and specify your old kernel and initramfs image. Please note: udev attempts to assign persistent names to most devices. If the way the kernel identifies your device changes from your old kernel version to the new one, udev may assume it's a new device and assign it an unexpected name. For example, the nForce ethernet drivers corrected a bug in the way the MAC address was read from the device. On my first boot what was usually my eth0 device was now my eth1 device. To fix this simply flush the offending rule from the /etc/udev/rules.d folder.
reboot
You will most likely need to reinstall your video driver at this point, if you used a proprietary binary version. Instructions for getting the latest driver and installing it can be found in the display drivers wiki.
For nVidia do this:
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/173.14.12/NVIDIA-Linux-x86_64-173.14.12-pkg2.run sh NVIDIA-Linux-x86_64-173.14.12-pkg2.run
Now it is a good idea to compare your lsmod output from your old kernel to the output of your new kernel. Just to be certain you didn't miss anything. I found the order to be different, so I copied the output to an Excel spreadsheet and sorted the two different lists. The only discrepancies I found were related to name changes in the kernel and AppArmor.