Showing posts with label building kernel 3.2.8 on debian. Show all posts
Showing posts with label building kernel 3.2.8 on debian. Show all posts

01 March 2012

89. Compiling kernel 3.2.8 on Debian Testing -- example using kernel-packages and kernel.org source

For kernel 3.2.9, see here: http://verahill.blogspot.com.au/2012/03/debian-testing-kernel-329.html

Following: http://www.linuxplanet.com/linuxplanet/tutorials/6853/1 and http://www.sysdesign.ca/guides/linux_kernel.html  and very much http://old-releases.ubuntu.com/ubuntu/dists/hoary/main/installer-ia64/current/doc/manual/en/ch08s04.html

Update: added kernel_headers

I've added very litte to the guides, except proving that yes, the above tutorial works for the current stable kernel version (3.2.8) and the current debian testing (29/12/2012).

Here's what's new in 3.2.8 -- https://lwn.net/Articles/484042/
Here's what will be new in 3.3 -- http://www.h-online.com/open/features/Kernel-Log-Linux-3-3-goes-into-testing-1418516.html

Everything between SAFE START and END are ok -- they won't change anything serious on your system. If you're building on a 32 bit system, have a look at the end of the post before launching the make.

--  SAFE START --
Install tools:
sudo apt-get install kernel-package fakeroot
(if you use apt-bugs you may get a warning about an lguest bug. Ignore it. Look at the bottom of the post for 32 bit issues and a simple solution.)


Get the latest STABLE release from http://kernel.org/
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.8.tar.bz2
It's 75 M and will take a wee while.
tar -xvf linux-3.2.8.tar.bz2
cd linux-3.2.8/

To get a head-start on a configuration file, see if you have one for your current kernel:
ls /boot/config-`uname -r`

If so (I know this is clunky, but the obvious solutions didn't work...)
echo "/boot/config-`uname -r` "|xargs cat > .config

I'm running 3.2.0-1.

Alright. Here's the thing. You shouldn't edit .config unless you know what you're doing. But then how will you ever learn? I don't yet know what I'm doing, so won't lead you into kernel-configuration related temptation.

Instead, we'll just learn how to build.

First
make oldconfig
which uses the .config

But it's not completely automatic -- when it comes to new features you'll have to provide input. Hitting enter i.e. accepting the default option is probably a good idea unless you think otherwise.

Alternatively, you do
make menuconfig
and pick everything you want


Here are the new features in 3.2.8 vs 3.2.0-1: 
  Cirrus Logic (Sound Fusion) New DSP support (SND_CS46XX_NEW_DSP) [Y/n/?] (NEW)
Agere Systems HERMES II Wireless PC Card Model 0110 (WLAGS49_H2) [N/m/?] (NEW)
 Linksys HERMES II.5 WCF54G_Wireless-G_CompactFlash_Card (WLAGS49_H25) [N/m/?] (NEW) 
Y means compile into kernel, m makes a loadable module and no means no.

Now build!
make-kpkg clean
The next step takes forever, in particular if you only use one core (>1 h). It takes ca 50 minutes on an i5 with the -j5 switch. You'll also need around 6.5 Gb of free space for the compilation.
fakeroot make-kpkg -j4 --initrd --revision=3.2.8 kernel_image kernel_headers

where as usual 4 is the number of cores(3)+1. Adjust as necessary.

--SAFE END--

This really isn't dangerous, although you may not want to do it remotely without a back-up plan.

Install with
sudo dpkg -i ../linux-image-3.2.8_3.2.8_amd64.deb
sudo dpkg -i ../linux-headers-3.2.8_3.2.8_amd64.deb

That's it! You don't even have to bother with update-grub.

Reboot at your convenience and admire your handiwork:
uname -a

Linux boron 3.2.8 #2 SMP Wed Feb 29 19:27:04 EST 2012 x86_64 GNU/Lin

The deb built this way is ca 33 M, while the stock debian 3.2.0--1 is a slim 23 M.

Once you're confident that you can compile and install a kernel without mishap you can start to remove kernel modules to make it slimmer -- or start including modules of your own choosing.


Tried and tested on:
AMD Athlon II X3 (64 bit)
2 x AMD Phenom II X6 (64 bit)
Intel i5-2400 (64 bit)
Intel core 2  duo T5870 (laptop, 64 bit)
Intel Celeron 1.6 GHz (32 bit)
-- all running debian testing.


Building on 32 bit

I had some issues on an Intel Celeron 1.6 GHz 32 bit due to a bug:
make[1]: Leaving directory `/home/me/tmp/linux-3.2.8'
/usr/bin/make    ARCH=i386 \
    -C Documentation/lguest
make: *** Documentation/lguest: No such file or directory.  Stop.
make: *** [debian/stamp/build/kernel] Error 2

The failure was pretty annoying...
real 157m58.192s
user 132m27.049s
sys 12m5.589s
There's a simple solution in a forum post at http://billy.com.mx/archives/660:

"I solved it by creating a symlink Documentation/lguest to Documentation/virtual/lguest"
that means (on one line)
ln -s /home/me/tmp/linux-3.2.8/Documentation/virtual/lguest  Documentation/lguest


That's all.


Check:
ls Documentation/lguest -lah
Documentation/lguest -> /home/me/tmp/linux-3.2.8/Documentation/virtual/lguest

ls Documentation/lguest/
extract  lguest.c  lguest.txt  Makefile

And once it's installed:
uname -a
Linux kookaburra 3.2.8 #3 SMP Thu Mar 1 14:43:45 EST 2012 i686 GNU/Linu


Modules
To get a list over the modules in use on your current system:
lsmod | gawk '{printf("%s ",$1)}'| sed 's/Module//g'

zlib_deflate crc32c libcrc32c ufs qnx4 hfsplus hfs minix ntfs vfat msdos fat jfs xfs reiserfs ext3 jbd ext2 pci_stub vbok8 mperf cpufreq_stats cpufreq_conservative cpufreq_powersave cpufreq_userspace ppdev bnep rfcomm bluetooth binfmt_misc as nfs_acl sunrpc kvm_amd kvm xt_state ipt_REJECT ipt_LOG xt_limit xt_tcpudp xt_conntrack iptable_mangle ipt_MASQUERADE ip
le_filter ip_tables x_tables hwmon_vid lp loop snd_hda_codec_hdmi arc4 rt2800usb rt2800lib crc_ccitt rt2x00usb rt2x00lib xer_oss snd_usb_audio snd_pcm snd_hwdep snd_usbmidi_lib nvidia hid_logitech_dj mac80211 joydev snd_seq_midi cfg80211 rfki5100_tco snd_timer snd_seq_device edac_core edac_mce_amd parport_pc parport snd i2c_piix4 soundcore pcspkr k10temp i2c_combcache jbd2 crc16 usb_storage uas sd_mod crc_t10dif ata_generic pata_atiixp ohci_hcd thermal thermal_sys floppy ahci lib
You can use that as a source of inspiration for what to keep and what to trim.