Difference between revisions of "Upgrading the Kernel"

From LinuxMCE
Jump to: navigation, search
(Added media directors. Fixed minor errors.)
(Media Directors)
Line 121: Line 121:
  
 
==Media Directors==
 
==Media Directors==
In a traditional installation the Core and Media Directors all run the Gutsy 2.6.22-14 kernel. If you want the media directors to continue to use this old kernel then you must fix a small bug in the Diskless_InstallKernel.sh script. This script assumes that media directors will run the same kernel version as the core. A temporary fix is to edit the /usr/pluto/bin/Diskless_InstallKernel.sh file and replace "Moon_KernelVersion=$(uname -r)" with "Moon_KernelVersion=2.6.22-14". Similarlly, the string "`uname -r`" in /usr/pluto/bin/Diskless_BuildDefaultImage.sh must be replaced with "2.6.22-14".  And again in /usr/pluto/bin/Diskless_Setup.sh (replaced
+
===Use old kernel===
 +
In a traditional installation the Core and Media Directors all run the Gutsy 2.6.22-14 kernel. If you want the media directors to continue to use this old kernel then you must fix a small bug in the Diskless_InstallKernel.sh script. This script assumes that media directors will run the same kernel version as the core. A temporary fix is to edit the /usr/pluto/bin/Diskless_InstallKernel.sh file and replace "Moon_KernelVersion=$(uname -r)" with "Moon_KernelVersion=2.6.22-14". Similarlly, the string "`uname -r`" in /usr/pluto/bin/Diskless_BuildDefaultImage.sh must be replaced with "2.6.22-14".   
 +
 
 +
Re-run scripts to build configs and symlinks.
 +
/usr/pluto/bin/Diskless_Setup.sh
 +
for md in /usr/pluto/diskless/*; do
 +
md_device=`echo "$md" | sed -e 's/.*[/]\([^/]\)/\1/g'`
 +
/usr/pluto/bin/Diskless_InstallKernel.sh $md_device
 +
done
 +
/usr/pluto/bin/Diskless_BuildDefaultImage.sh
 +
 
 +
===Use new kernel===
 +
Another route is to use your new kernel on the media directors as well. You can do this by copying your kernel to each MD root filesystem. Additionally, you will need to add the kernel image to the MD root archive (/usr/pluto/install/PlutoMD-xxxyyy.tar.bz2) where xxxyyy is your architecture.
  
A more popular route is to push your kernel to the media directors as well. You can do this by copying your kernel to each MD root filesystem. Additionally, you will need to add the kernel image to the MD root archive (/usr/pluto/install/PlutoMD-xxxyyy.tar.bz2) where xxxyyy is your architecture.
 
 
'''Note: You should build the same kernel for both 32-bit and 64-bit architectures.'''
 
'''Note: You should build the same kernel for both 32-bit and 64-bit architectures.'''
 +
 +
'''Warning: Make sure your initramfs file is around 10MB. If you have kernel debugging enabled the file will be too large to transfer over tftp and net boots will fail.'''
 
  for md in /usr/pluto/diskless/*; do
 
  for md in /usr/pluto/diskless/*; do
 
  cp /boot/vmlinuz-2.6.26.5 $md/boot/
 
  cp /boot/vmlinuz-2.6.26.5 $md/boot/
Line 139: Line 152:
 
  rm -rf moonfs
 
  rm -rf moonfs
  
As a final step, you should rebuild the kernel symlinks and the pxeconfigs.
+
As a final step, copy the kernel to existing media directors, and rebuild symlinks.  
 
  for md in /usr/pluto/diskless/*; do
 
  for md in /usr/pluto/diskless/*; do
 
  md_device=`echo "$md" | sed -e 's/.*[/]\([^/]\)/\1/g'`
 
  md_device=`echo "$md" | sed -e 's/.*[/]\([^/]\)/\1/g'`
Line 146: Line 159:
 
  cp /boot/initrd.img-2.6.26.5 $md/boot
 
  cp /boot/initrd.img-2.6.26.5 $md/boot
 
  done
 
  done
 +
/usr/pluto/bin/Diskless_BuildDefaultImage.sh

Revision as of 04:32, 11 September 2008


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 recent 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 on how 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. Always keep your old, working kernel on hand.

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 non-existant config options. This is simply due to the removal or renaming of old options. Most of these warnings are insignificant, and enabled by default in the vanilla kernel. I would quickly go over the list of warnings 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.

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

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
  • Selected preemptive kernel (low latency)
  • Build SATA driver into kernel
  • Build MD,RAID1,RAID5 modules into kernel
  • Build NIC module into kernel
  • Disabled kernel debugging (Note: This is very important if you plan to use this kernel

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 more up-to-date than the Gutsy versions.

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. The compilation and installation is so straight forward that there's no reason to play around with mixmatched versions. Just rebuild both the kernel drivers and the userspace utilities. 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. I ran into even more drama with LIRC, because many drivers failed to even attempt a build. I was able to manually enter each driver directory and perform a make/make install. After applying the patch to the kernel, it failed to compile as well. At this point I would assume that LIRC is not working with 2.6.26.5.

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.

Media Directors

Use old kernel

In a traditional installation the Core and Media Directors all run the Gutsy 2.6.22-14 kernel. If you want the media directors to continue to use this old kernel then you must fix a small bug in the Diskless_InstallKernel.sh script. This script assumes that media directors will run the same kernel version as the core. A temporary fix is to edit the /usr/pluto/bin/Diskless_InstallKernel.sh file and replace "Moon_KernelVersion=$(uname -r)" with "Moon_KernelVersion=2.6.22-14". Similarlly, the string "`uname -r`" in /usr/pluto/bin/Diskless_BuildDefaultImage.sh must be replaced with "2.6.22-14".

Re-run scripts to build configs and symlinks.

/usr/pluto/bin/Diskless_Setup.sh
for md in /usr/pluto/diskless/*; do
md_device=`echo "$md" | sed -e 's/.*[/]\([^/]\)/\1/g'`
/usr/pluto/bin/Diskless_InstallKernel.sh $md_device
done
/usr/pluto/bin/Diskless_BuildDefaultImage.sh

Use new kernel

Another route is to use your new kernel on the media directors as well. You can do this by copying your kernel to each MD root filesystem. Additionally, you will need to add the kernel image to the MD root archive (/usr/pluto/install/PlutoMD-xxxyyy.tar.bz2) where xxxyyy is your architecture.

Note: You should build the same kernel for both 32-bit and 64-bit architectures.

Warning: Make sure your initramfs file is around 10MB. If you have kernel debugging enabled the file will be too large to transfer over tftp and net boots will fail.

for md in /usr/pluto/diskless/*; do
cp /boot/vmlinuz-2.6.26.5 $md/boot/
cp /boot/initrd.img-2.6.26.5 $md/boot/
done
cd /tmp
mkdir moonfs_amd64
cd moonfs_amd64
tar -jxvf /usr/pluto/install/PlutMD-adm64.tar.bz2
cp /boot/vmlinuz-2.6.26.5 boot
cp /boot/initrd.img-2.6.26.5 boot
tar -jcvpf /usr/pluto/install/PlutoMD-adm64.tar.bz2 *
cd ..
rm -rf moonfs

As a final step, copy the kernel to existing media directors, and rebuild symlinks.

for md in /usr/pluto/diskless/*; do
md_device=`echo "$md" | sed -e 's/.*[/]\([^/]\)/\1/g'`
/usr/pluto/bin/Diskless_InstallKernel.sh $md_device
cp /boot/vmlinuz-2.6.26.5 $md/boot
cp /boot/initrd.img-2.6.26.5 $md/boot
done
/usr/pluto/bin/Diskless_BuildDefaultImage.sh