First of all, I want to say thanks to Agios for the original how-to as that is where this one comes from. Agios's version is located here: Ubunut Kernel The information he got and put together came from this how-to originally: Kernel Compile
Below are the steps Agios and I have both followed exactly to build the 2.6.17.7 kernel deb packages without any issues at all so far. It *should* work for you. However, be warned that you might need to add support for things like wireless internet and other things. This how-to also tells how to install the Nvidia drivers. Unfortunately, neither of us use ATI, so it won't tell you how to do that.
Ubuntu discourages compiling your own kernel. However, I not only wanted this ability I needed it for my hardware. I referenced a thread on the Ubuntu forums and compiled a new kernel from kernel.org using the following steps.
Become root and make sure you have the required packages installed.
sudo su - apt-get install build-essential bin86 kernel-package libqt3-headers libqt3-mt-dev wget
Download the desired kernel source from kernel.org to the /usr/src directory. Extract it and set up the linux symbolic link.
cd /usr/src wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.6.tar.bz2 tar xvjf linux-2.6.17.6.tar.bz2 rm -rf linux ln -s /usr/src/linux-2.6.17.6 linux
Navigate to the kernel sources top level directory.
cd /usr/src/linux
If you have any kernel patches to apply, do it now.
patch p1 <my.patch
Assuming you don't want to configure the kernel from scratch, copy over your current kernel config.
cp /boot/config-`uname -r` .config
Configure the new kernel. You cannot run xconfig from a root login shell so get out of root and use kdesu.
exit cd /usr/src/linux kdesu make xconfig
Once you run the above command, a window labeled qconf should popup on your screen. This is where you can tweak the settings of the kernel. You will need to disable 3 settings for sure or it's a good possibility that the build will error on your. First you'll want to find the 'Multimedia Devices' section and expand it if necessary. Then you will need to find the 'Digital Video Broadcasting Devices' section and click on it. When you do, it should bring up some information in the panel on the right. There are 3 check boxes for Budget cards. Make sure they are empty.
You'll also want to make a couple of other minor tweaks that I suggest. Go to the Processor type and features section and set the processor type accordingly to whatever type of processor you have. I have also set the 'Preemption Model' to 'Voluntary' and the 'Time Frequency' I set to '1000'. Click on 'Save' at the top and then you can proceed with the next steps.
You want to set the following options as well. Below is a very generic description of what you should do. It's for enabling iptables stuff within the kernel. Without setting these values below, you will not have iptables functionality in your new kernel once it's built.
Networking -> Networking options -> Network packet filtering:
Core Netfilter Configuration - select ALL options as modules. IP: Netfilter Configuration - select ALL options except the EXPERIMENTAL options as modules. By ALL I mean every option under those sections that can be configured.
Device Drivers:
If you want sensors to work select the I2C options.
If you are using a config from a previous running kernel most everything else should be set for you. If you want to lean up your kernel you can go through the various options and deselect those for hardware you know you don't have. I typically just leave them in. I would not make a lot of changes at once lest you end up with a broken kernel with no idea what specific change you made to break it.
sudo su - cd /usr/src/linux
Compile the kernel. You may change the revision from 686 to whatever you wish. i.e. 386, k7, etc. The clean step runs quickly but the make-pkg -initrd command takes a long time based on your system. Expect 1 - 3 hours.
make-kpkg clean make-kpkg -initrd --revision=686 kernel_image kernel_headers modules_image
The steps above will create two deb files in /usr/src. Install them as follows:
cd /usr/src dpkg -i kernel-headers-2.6.17.6_686_i386.deb dpkg -i kernel-image-2.6.17.6_686_i386.deb
I have a Nvidia video card and use the proprietary drivers. Installing a new kernel requires reinstallation of the Nvidia drivers too. Unfortunately you need to do this while running the new kernel. In preparation I downloaded and extracted the nvidia kernel source.
apt-get install nvidia-kernel-source cd /usr/src/ tar zxvf nvidia-kernel-source.tar.gz
Then rebooted to the new kernel in recovery mode to keep X from trying to start and completed the nvidia install.
cd /usr/src/modules/nvidia-kernel/nv/ make module make install
Then reboot normally and you should be up and running with your new kernel!
To clean up old unused kernels use apt-get remove if you installed them with apt. If you rolled your own kernel with the instructions above then use dpkg --purge to remove the two deb packages you installed above. You can also delete any applicable files and directorys for the old kernel in /usr/src. Kernel files are located in the following places:
/boot/grub/menu.lst /boot /usr/src /lib/modules /usr/share/doc/kernel*
I learned a long time ago that it is wise to keep the kernel source for your live kernels, just in case. If you are running a Ubuntu kernel you can get the source by installing the appropriate linux-source-<version> package.
Automated kernel install script
The script below can be used to automate the kernel install procedure. Steps 1. and 2. must have been done prior to using the script. I recommend that you manually perform all the steps at least once before using this script. The script has several options. One of these options will reboot the system to activate the new kernel. This is only for brave souls who are confident the previous steps will work successfully. You should also be aware that the grub option strips the "quiet" and "splash" boot options from ALL the boot sections in menu.lst. You may or may not desire this. Use this script at your own risk!
#!/bin/bash
#
# newkernel --extra-version=01 --nodownload --reboot version
#
# This script must be run from a root prompt or via sudo
#
# Agios 09/04/2006 Version 0.1.0
# Agios 09/11/2006 Version 0.2.0 Better selection of DEB package name.
#
EV=01
DL=1
REBOOT=0
GRUB=0
VERSION=0
USAGE=0
while [ "$1" != "" ]; do
case $1 in
-e | --extra-version) shift
EV=$1;;
--extra-version=) EV=${1:15};;
-n | --nodownload) DL=0;;
-r | --reboot) REBOOT=1;;
-g | --grub) GRUB=1;;
-h | --help) USAGE=1;;
* ) VERSION=$1;;
esac
shift
done
# if usage=1 print or if version=0 print usage and exit
if (($USAGE)) || [ "$VERSION" = 0 ]; then
echo ' '
echo 'Usage: newkernel [options] version'
echo ' '
echo ' -e | --extra-version Defaults to 01'
echo ' -n | --nodownload Do not download or extract source'
echo ' -r | --reboot Reboot to activate the new kernel.'
echo ' -g | --grub Edit Grub menu.lst to remove quiet splash'
echo ' -h | --help Print this text and exit.'
echo ' '
echo 'Example: newkernel --extra-version=02 2.6.17.12'
echo ' newkernel -g -r 2.6.17.10'
echo ' '
exit
fi
# verify we are uid 0
if [ "$UID" -ne 0 ]
then
echo "You must be root to run this script."
exit
fi
# conditional download and unpackage
if (($DL)); then
cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-$VERSION.tar.bz2
tar -xvjf linux-$VERSION.tar.bz2
rm -rf linux
ln -s /usr/src/linux-$VERSION linux
fi
cd /usr/src/linux
cp /boot/config-`uname -r` .config
make oldconfig
make-kpkg clean
make-kpkg --initrd --append_to_version=-$EV kernel_image
cd /usr/src
PKG='kernel-image-'$VERSION'-'$EV'*.deb'
dpkg -i `/bin/ls $PKG`
# conditional sed out quiet and splash from grub menu.lst
if (($GRUB)); then
cd /boot/grub
rm -f menu.bak
cp menu.lst menu.bak
sed 's/quiet splash //' menu.bak >menu.lst
fi
# conditional reboot if -r or --reboot was specified
if (($REBOOT)); then
echo Rebooting now!
reboot
fi
exit
