Published at: 01:07 pm - Monday July 25 2011
Last week and how it had been announced, Linus Torvalds released the new version of the Linux Kernel series 3.0
Because of this and the request of several geeks friends, I write this small handbook.
Compile the Kernel Source, the Debian way.
/me laughs while caresses her black cat, muahaha muahaha
Almost all my nerds friends are afraid to “El Coco“, unfaithful girlfriends and to compile the Kernel. Well the first two things they have no solution but compile the kernel it’s easy.
I – Know your hardware.
Knowing your hardware is the key, we can use basic system tools or external tools, I prefer the basic (we’re old school nerd!).
Processor: cat /proc/cpuinfo
root@skynet:~# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 14
model name : Intel(R) Core(TM) Duo CPU T2300 @ 1.66GHz
stepping : 12
cpu MHz : 1596.289
cache size : 6144 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr mce cx8 apic mtrr pge mca cmov clflush mmx fxsr sse sse2 constant_tsc up pni monitor
bogomips : 3192.57
clflush size : 64
cache_alignment : 64
address sizes : 32 bits physical, 32 bits virtual
power management:
root@skynet:~#
Memory: cat /proc/meminfo
root@skynet:~# cat /proc/meminfo
MemTotal: 514584 kB
MemFree: 15152 kB
Buffers: 38864 kB
Cached: 149592 kB
SwapCached: 2236 kB
Active: 201248 kB
Inactive: 273780 kB
root@skynet:~#
PCI Bus: lspci (we can use the option -vv for verbose mode)
root@skynet:~# lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH Graphics Adapter
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
00:04.0 System peripheral: InnoTek Systemberatung GmbH Service
00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)
00:06.0 USB Controller: Apple Computer Inc. KeyLargo/Intrepid USB
00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:0b.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller
00:0d.0 SATA controller: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller (rev 02)
root@skynet:~#
USB: lsusb (also has the -vv option)
root@skynet:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
root@skynet:~#
At this point you know your hardware, but you know wich driver is using? don’t worry, the kernel configuration is too intuitive (knowing our hardware, course).
However Kenshi Muto (a Debian Developer) has made this process easier:
http://kmuto.jp/debian/hcl/ – Device driver check & report.
In this website you paste the lspci -n output and show us wich driver is used for our hardware, nice right?.
II – Getting the tools
We need some tools for this adventure
# apt-get install kernel-package dpkg-dev debianutils binutils libncurses5-dev
And of course the Kernel source, in kernel.org are the latest stable and experimental versions.
# wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.bz
And … I’m pretty sure that I forget something mmmm oooh yes, the last item: beer (without her this adventure can being bored). Now we are ready to the party compile.
III – Compiling
Ready for the party?
Unpacking the source:
# tar xvjf linux-3.0.tar.bz2 -C /usr/src/
Go to /usr/src and see that there are your old and new sources, we’ll working into the new sources:
root@skynet:~# cd /usr/src/
root@skynet:/usr/src# ls
linux-3.0 linux-headers-2.6.38-2-686 linux-headers-2.6.38-2-common linux-kbuild-2.6.38
root@skynet:/usr/src# cd linux-3.0/
root@skynet:/usr/src/linux-3.0#
Cleaning (if is the first time that unpacking the source, you can forget this step)
# make-kpkg clean
To the next point there are several options:
make config – Plain text interface.
make menuconfig – Text based color menus, radiolists & dialogs.
make nconfig – Enhanced text based color menus.
make xconfig – X windows (Qt) based configuration tool.
make gconfig – X windows (Gtk) based configuration tool.
make oldconfig – Default all questions based on the contents of your existing ./.config file and asking about new config symbols.
The easy way (and this post it’s about easy things) is using: make oldconfig.
Copy your old .config file into the new source path.
root@skynet:/usr/src/linux-3.0# cp /boot/config-`uname -r` .config
root@skynet:/usr/src/linux-3.0# make oldconfig
....
#
# configuration written to .config
#
root@skynet:/usr/src/linux-3.0#
If you forget something or just want play, test or broke your Kernel can run: make menuconfig when you finished, exit and save it. Make the image:
root@skynet:/usr/src/linux-3.0# make-kpkg clean
root@skynet:/usr/src/linux-3.0# make-kpkg --initrd kernel_image kernel_headers --revision 01 --append_to_version -lab
Where:
–initrd – To make a initrd for the boot.
kernel_image – Need explain this?
kernel_headers – To build the headers package of the image
–revision – Set the number of revision that the package will have to control future compilations.
–apend_to_version – Set the extraversion in the name of image (to personalize your Kernel).
While you kernel is compiling, I recommend you go for a couple of beers, yes … this will take a long time.
[...]
When the compilation is finishing you must see the packages created.
root@skynet:/usr/src/linux-3.0# ls ../
linux-3.0 linux-headers-3.0.0-lab_01_i386.deb
linux-headers-2.6.38-2-686 linux-image-3.0.0-lab_01_i386.deb
linux-headers-2.6.38-2-common linux-kbuild-2.6.38
linux-headers-3.0.0-lab
root@skynet:/usr/src/linux-3.0#
Almost done! Install the new Kernel packages
root@skynet:/usr/src/linux-3.0# cd ..
root@skynet:/usr/src# dpkg -i *.deb
Assuming your directory is clean, or install one by one.
Now reboot and pray choose the new Kernel.
Booyah!
root@skynet:~# uname -a
Linux skynet 3.0.0-lab #20 SMP Mon Jul 25 11:10:28 CDT 2011 i686 GNU/Linux
root@skynet:~#
Happy Hacking!