Customizing & Installing Linux Kernel on Debian Wheezy
Here is a quickie for customizing and install Linux kernel 3.5.x on Wheezy.
Add yourself (with account username) to sudoer group:
# adduser username sudo
You need to logout and login for this change to take effect. You also
need to be able to use
su to install the new kernel in
Install some packages and kernel source:
$ sudo aptitude update $ sudo aptitude install kernel-package pkg-config bzip2 g++ libncurses5-dev fakeroot bc $ sudo aptitude install libqt4-dev
libqt4-dev is only necessary if you wish to use
xconfig instead of
make menuconfig below.)
The kernel packaged for Wheezy is at version 3.2. Source code for a more up-to-date kernel version can be obtained from kernel.org and saved somewhere. You just need to expanding the compressed source somewhere (even under your home directory, which is the case in this post).
Either way, the customization procedure is similar; when you expand
the source tree (e.g., the
tar statement below), you just need to
specify the source tarball you wish to use. Here I just follow the
$ sudo aptitude install linux-source-3.2
Extract the source tree:
$ cd ~/src $ tar -jxf /usr/src/linux-source-3.2.tar.bz2 ... or use tar -Jxf for .tar.xz file ... $ ln -s linux-source-3.2 linux $ cd linux
EXTRAVERSION entry in Makefile, as in:
EXTRAVERSION = .20120929.1
for example to add
.20120929.1 to the kernel version number. This
is convenient for keeping the existing, working kernels around when
you need to recompile with different options.
menuconfig to customize the kernel
options. Before the
make-kpkg lines, setting concurrency (most
likely to the number of cores of my processor) is optinal but having a
higher number typically reduces the compilation time.
$ make mrproper $ make xconfig # or make menuconfig $ export CONCURRENCY_LEVEL=2 # for dual-core; this is optional $ fakeroot make-kpkg clean $ fakeroot make-kpkg --initrd kernel_image ... fakeroot might fail; when it does, try running make-kpkg commands as root ... $ sudo dpkg -i ../linux-image-3.2.20120929.*_amd64.deb
Upon reboot in the GRUB menu you will find the newly installed kernel:
$ sudo reboot
Purging Old Kernel Image from System
For example, if the kernel to be uninstalled is of version 2.6.26 and the extra version that I used was 20091112.1, do:
$ sudo dpkg -P linux-image-126.96.36.19991112.1
That’s it. However it is often a good idea to keep at least one kernel image that I know for sure to work so that when a custom kernel fails, I have something to fall back on. On the other hand, it is also a good idea to purge very old kernel images to save space in /boot.