Debian with a vanilla kernel
So one might want to ask why you’d want to sacrifice the fantastic stability and openness of Debian to install a vanilla (= original) kernel (Debian currently has 2.6.32). There are quite a few reasons for doing so. For example, the current kernel (2.6.38) has TRIM support, which is something I am looking for when using SSDs. Also, maybe you want to have a bleeding edge kernel just for the fun of it. So lets get started.
First order of business is to download a few packages, download the latest kernel from kernel.org and then unpack the kernel in /usr/src/:
root@chimera:~# aptitude install fakeroot build-essential kernel-package debhelper dpkg-dev ncurses-dev root@chimera:~# cd /usr/src root@chimera:/usr/src# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-220.127.116.11.tar.bz2 root@chimera:/usr/src# tar xjf linux-18.104.22.168.tar.bz2
Then, since we want to build the kernel as a normal user and not as root, we add a user to the “src” group and set the owner group of the unpacked kernel folder to “src”. After that, there is no reason to be root anymore, so logout:
root@chimera:/usr/src# usermod -aG src simon root@chimera:/usr/src# chown root:src -R linux-22.214.171.124 root@chimera:/usr/src# chown root:src /usr/src/ root@chimera:/usr/src# chmod 775 src/ root@chimera:/usr/src# logout simon@chimera:~$
Now we can actually configure the kernel. To do so, change to the previously unpacked kernel directory and configure the kernel using “make menuconfig”.
simon@chimera:~$ cd /usr/src/linux-126.96.36.199/ simon@chimera:/usr/src/linux-188.8.131.52$ make menuconfig
Here you can make all your desired changes and apply all your tweaks. It is always a good idea to configure the correct processor family under “Processor type and features” -> “Processor family”. When you are done exploring and applying all your tweaks, exit the configuration utility and make sure to save your configuration. Then, make sure your configuration was saved successfully by looking for the “.config” file in the current folder:
simon@chimera:/usr/src/linux-184.108.40.206$ ls -la [..] -rw-r--r-- 1 simon simon 123150 May 8 13:57 .config [..]
So let’s get cracking now. Since building the kernel can take a long time, we want to use all of our available CPU cores. Personally, I am using the Amazon EC2 service to build this kernel. By using an “c1.xlarge” instance, I have access to 8 logical cores. So set up the CONCURRENCY_LEVEL environment variable:
simon@chimera:/usr/src/linux-220.127.116.11$ grep processor /proc/cpuinfo | wc -l 8 simon@chimera:/usr/src/linux-18.104.22.168$ export CONCURRENCY_LEVEL=8
Build the kernel and kernel headers by issuing the following command. Note that you should change the “append_to_version” and “revision” parameters to fit it your needs.
simon@chimera:/usr/src/linux-22.214.171.124$ fakeroot make-kpkg --initrd --append_to_version -krenger.1+xeon-aws --revision=1 kernel_image kernel_headers
Now go and have a coffee, because even on an 8-core machine, the build took about 20 minutes. When the build finishes, you should have two new DEB packages in your /usr/src/ folder. Install the kernel by issuing the following command:
root@chimera:/usr/src# dpkg -i linux-image-126.96.36.199-krenger.1+xeon-aws_1_amd64.deb
If necessary, update your GRUB configuration (/boot/grub/menu.lst or /boot/grub/grub.cfg, depening on your Debian version) and add your newly installed kernel to the list of available kernels. Then, reboot your machine to test your new kernel out and verify that you are running your shiny new kernel by issuing:
simon@chimera:~$ uname -a Linux chimera.krenger.ch 188.8.131.52-krenger.1+xeon-aws #2 SMP Sun May 8 14:34:44 UTC 2011 x86_64 GNU/Linux