HOWTO: Compiling a custom Linux kernel on Debian Linux System
Purpose: There are many ways on how to compile a Linux kernel on a Linux operating system. Here is a step-by-step guide on how to compile a custom Linux kernel, the “Debian way”, on Debian Lenny.
Step 1: Install Debian system
I guess I don’t need to explain this. If you are at a stage where you want to compile your own kernel you probably already know how to install Debian Linux.
Step 2: Download sources
# apt-get install wget bzip2
Download kernel sources either from www.kenel.org by following:
# cd /usr/src
# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.26.tar.bz2
# tar xjf linux-2.6.26.tar.bz2
# ln -s linux-2.6.26 linux
# cd /usr/src/linux
or
You can down kernel sources from Debian repository using:
# apt-get install linux-source-2.6.26
# cd /usr/src/
# tar -xjvf linux-source-2.6.26.tar.bz2
# ln -s linux-source-2.6.26 linux
# cd /usr/src/linux
Step 3: Setup the Kernel configuration program
You will need to install the following packages on your system for successfully compiling the Linux kernel.
# apt-get install kernel-package fakeroot build-essential libqt3-mt-dev
Note: Here I am assuming that you are going to configure your kernel from a GNOME environment.
Step 4: Get a kernel config file (.confg)
There are two ways to do that:
Method 1: From an existing (usually older) kernel config file.
# cp /boot/config-2.6.24-1-686 /usr/src/linux/.config
# make oldconfig
Method 2: Generate a default config file
# make defconfig
Step 5: Configure the kernel options
# make xconfig
Select or deselect the items that you want or not want respectively.
Step 6: Compile the kernel
Now it’s time to compile all your hard work.
# make-kpkg --initrd --append-to-version=-mycustomkernel kernel_image kernel_headers
or if you know your kernel will boot without initrd then you can give following command:
# make-kpkg --append-to-version=-mycustomkernel kernel_image kernel_headers
or if you do not want to install the kernel headers for out-of-tree kernel module compilation, give the command:
# make-kpkg --initrd --append-to-version=-mycustomkernel kernel_image
and your resulting kernel will be called as 2.6.26-mycustomkernel in a deb package format.
Step 7: Install your kernel
# dpkg -i linux-image-2.6.26-mycustomkernel_2.6.26-mycustomkernel-10.00.Custom_i386.deb
Step 8: Reboot
Finally you can reboot your system and select your new kernel from your boot loader (typically GRUB) menu.
Additional Notes
If you have multiple core machine (like a dual-core), you can almost double up the kernel compilation speed i.e. in other words reduce your compilation time to almost half.
Happy Compiling!


Email Subscription









October 20th, 2010 at 12:24 am
[...] the rest here: how to custom compile Linux kernel on Debian Linux | Organizing … Posted in: Kernels ADD [...]
July 5th, 2011 at 4:05 pm
This is likely wrong without initrd
Reply to this comment
September 23rd, 2011 at 1:50 pm
The comment has been moderated to remove objectionable stuff.
====== making target debian/stamp/install/linux-image-3.1.0-rc7-evil.custom [new prereqs: ]======
This is kernel package version 11.015.
echo “The UTS Release version in include/linux/version.h”; echo ” \”\” “; echo “does not match current version:”; echo ” \”3.1.0-rc7-evil.custom\” “; echo “Please correct this.”; exit 2
The UTS Release version in include/linux/version.h
“”
does not match current version:
“3.1.0-rc7-evil.custom”
Please correct this.
make[1]: *** [debian/stamp/install/linux-image-3.1.0-rc7-evil.custom] Error 2
make[1]: Leaving directory `/home/devadmin/source/torvalds-linux-4cf670b’
make: *** [kernel_image] Error 2
Anyone know ??? is up with this error????
Reply to this comment