<< Back to man.lupaworld.com


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ A ] [ next ]

Debian Reference
Chapter 7 - The Linux kernel under Debian


Debian has its own method of recompiling the kernel and related modules. See also Debian and the kernel, Section 2.7.


7.1 Kernel recompile

The use of gcc, binutils, and modutils from Debian unstable may help when compiling the latest Linux kernel. See /usr/share/doc/kernel-package/README.gz, especially the bottom of this, for the official information.

Since it is a moving target, kernel compilation is a difficult subject that may confuse even the most admired developer:

Manoj Srivastava wrote:
--initrd requires a Debian-only cramfs patch.
Herbert Xu wrote:
No it does not, all you have to do to use a filesystem other than CRAMFS is to set MKIMAGE in /etc/mkinitrd/mkinitrd.conf.

Be careful and always rely on the /usr/share/doc/kernel-package/README.gz by Manoj and Kent. Make sure to obtain the latest unstable version of the kernel-package package if you are to compile the latest version of the kernel.

initrd is not needed for a kernel compiled only for one machine. I use it since I want my kernel to be almost the same as the one provided by the kernel-image packages. If you use initrd, make sure to read mkinitrd(8) and mkinitrd.conf(5). See also http://bugs.debian.org/149236.


7.1.1 Debian standard method

Watch out for bug reports on kernel-package, gcc, binutils, and modutils. Use new versions of them as needed.

Compiling a custom kernel from source under a Debian system requires special care. Use the new --append_to_version with make-kpkg to build multiple kernel-images.

     # apt-get install debhelper modutils kernel-package libncurses5-dev
     # apt-get install kernel-source-2.4.18   # use latest version
     # apt-get install fakeroot
     # vi /etc/kernel-pkg.conf                # input name and email
     $ cd /usr/src                            # build directory
     $ tar --bzip2 -xvf kernel-source-2.4.18.tar.bz2
     $ cd kernel-source-2.4.18                # if this is your kernel source
     $ cp /boot/config-2.4.18-386 .config     # get current config as default
     $ make menuconfig                        # customize as one wishes
     $ make-kpkg clean                        # must run (per: man make-kpkg)
     $ fakeroot make-kpkg --append_to_version -486 --initrd \
             --revision=rev.01 kernel_image \
             modules_image # modules_image is for pcmcia-cs* etc.
     $ cd ..
     # dpkg -i kernel-image*.deb pcmcia-cs*.deb # install

make-kpkg kernel_image actually does make oldconfig and make dep. Do not use --initrd if initrd is not used.

If one wants to use modules from pcmcia-cs or no pcmcia, one should select "General setup —>" to "PCMCIA/CardBus support —>" in make menuconfig and set the configuration to "< > PCMCIA/CardBus support" (i.e., uncheck the box).

On an SMP machine, set CONCURRENCY_LEVEL according to kernel-pkg.conf(5).


7.1.2 Classic method

Get pristine sources from:

or use equivalent sources in Debian and do the following:

     # cd /usr/src
     # tar xfvz linux-whatever.tar.gz
     # rm -rf linux
     # ln -s linux-whatever linux
     # tar xfvz pcmcia-cs-whatever.tar.gz
     # ln -s pcmcia-cs-whatever pcmcia
     # cd linux
     # make menuconfig
     ... configure stuff ...
     # make dep
     # make bzImage
     ... edits for lilo / grub ...
     ... move /usr/src/linux/arch/i386/boot/bzImage to boot ...
     ... /sbin/lilo or whatever you do for grub
     # make modules; make modules_install
     # cd ../pcmcia
     # make config
     # make all
     # make install
     ... add needed module names to /etc/modules
     # shutdown -r now
     ... boot to new kernel ...

7.1.3 Kernel headers

Most "normal" programs don't need kernel headers and in fact may break if you use them directly; instead they should be compiled against the headers with which glibc was built, which are the versions in /usr/include/linux and /usr/include/asm of the Debian system.

So do not put symlinks to the directories in /usr/src/linux from /usr/include/linux and /usr/include/asm, as suggested by some outdated documents.

If you need particular kernel headers for some kernel-specific application programs, alter the makefile(s) so that their include path points to dir-of-particular-kernel-headers/include/linux and dir-of-particular-kernel-headers/include/asm.


7.2 The modularized 2.4 kernel

The new Debian 2.4 kernels provided by kernel-image-2.4.NN are very modularized. You have to make sure those modules are activated to make the kernel function as you intend.

Although I have many examples for /etc/modules in the following section as a quick fix, I hear that the correct way to fix these module-related issues is to provide an alias for the device in a file in /etc/modutils/ since there are enough aliases available with current kernels. Some modules may be auto activated by hardware detection programs such as discover. See also Hardware detection for X, Section 9.4.2.

See Special provisions for dealing with modules, Section 2.7.5 and Documentation/*.txt in the Linux source for the precise information.


7.2.1 PCMCIA

/etc/modules may need to contain the following for some old PCMCIA to function:

     # ISA PnP driver
     isa-pnp
     # New Low level PCMCIA driver
     # yenta_socket # does not seem to be needed in my case

The rest is taken care of by PCMCIA scripts (from the pcmcia-cs package), depmod and kmod. I think I needed isa-pnp because my laptop is an old ISA-PCMCIA. Recent laptops with CardBus/PCMCIA may not require this.

Voice of the genius Miquel van Smoorenburg miquels@cistron.nl:

"I simply removed the entire pcmcia stuff from the laptop here at work, including the cardmgr etc and just installed a 2.4 kernel with cardbus support, and the new hotplug package from woody.

As long as you only have 32-bit cards you don't need the pcmcia package; 2.4 has card services built in. And the standard tulip driver should work fine with your dlink card.

—Mike."

See Linux PCMCIA HOWTO and Network configuration and PCMCIA, Section 10.10.5.


7.2.2 SCSI

[NOT TESTED] /etc/modules needs to contain the following for SCSI to function:

     # SCSI core
     scsi_mod
     # SCSI generic driver
     sg
     # SCSI disk
     sd_mod
     # All other needed HW modules
     ...

depmod may take care of some of the above modules.


7.2.3 Network function

/etc/modules needs to contain the following for extra network function:

     # net/ipv-4
     ip_gre
     ipip
     
     # net/ipv-4/netfilter
     # iptable (in order)
     ip_tables
     ip_conntrack
     ip_conntrack_ftp
     iptable_nat
     iptable_filter
     iptable_mangle
     #
     ip_nat_ftp
     ip_queue
     #
     ipt_LOG
     ipt_MARK
     ipt_MASQUERADE
     ipt_MIRROR
     ipt_REDIRECT
     ipt_REJECT
     ipt_TCPMSS
     ipt_TOS
     ipt_limit
     ipt_mac
     ipt_mark
     ipt_multiport
     ipt_owner
     ipt_state
     ipt_tcpmss
     ipt_tos
     ipt_unclean
     #
     #ipchains
     #ipfwadm

The preceding may not be optimized. depmod may take care of some of the above modules.


7.2.4 EXT3 filesystem ( > 2.4.17)

Enabling a journaling filesystem with the EXT3 FS involves the following steps using a Debian precompiled kernel-image ( > 2.4.17) package:

     # cd /etc; mv fstab fstab.old
     # sed 's/ext2/ext3,ext2/g' <fstab.old >fstab
     # vi /etc/fstab
     ... set root filesystem type to "auto" instead of "ext3,ext2"
     # cd /etc/mkinitrd
     # echo jbd >>modules
     # echo ext3 >>modules
     # echo ext2 >>modules
     # cd /
     # apt-get update; apt-get install kernel-image-2.4.17-686-smp
     ... install latest kernel and set up boot (lilo is run here)
     # tune2fs -j -i 0 /dev/hda1
     # tune2fs -j -i 0 /dev/hda2
     ... For all EXT2 FS's converted to EXT3
     # shutdown -r now

Now EXT3 journaling is enabled. Using ext3,ext2 as the fstab "type" entry ensures safe fallback to EXT2 if the kernel does not support EXT3 for non-root partitions.

If you have previously installed a 2.4 kernel and do not wish to reinstall, perform the above steps up to the apt-get commands, then:

     # mkinitrd -o /boot/initrd.img-2.4.17-686-smp /lib/modules/2.4.17-686-smp
     # lilo
     # tune2fs -j -i 0 /dev/hda1
     # tune2fs -j -i 0 /dev/hda2
     ... for all EXT2 FS's converted to EXT3
     # shutdown -r now

Now EXT3 journaling is enabled.

If /etc/mkinitrd/modules was not set when mkinitrd was run and you would like to add some modules at boot time:

     ... at initrd prompt to gain shell (5 sec.), type RETURN
     # insmod jbd
     # insmod ext3 # modprobe ext3 may take care of everything
     # insmod ext2
     # ^D
     ... continue booting

At the system boot screen (dmesg), "cramfs: wrong magic" may appear but this is known to be harmless. This issue has been resolved in Sarge (2002/10). See http://bugs.debian.org/135537 and the EXT3 File System mini-HOWTO or /usr/share/doc/HOWTO/en-txt/mini/extra/ext3-mini-HOWTO.gz for more information.

Some systems are reported to experience severe kernel lockup if EXT3 is enabled but I had no problem (as of 2.4.17).


7.2.5 Realtek RTL-8139 support in 2.4

For whatever reason, the RTL-8139 support module is no longer called rtl8139, it's now called 8139too. Just edit your /etc/modules to reflect this change when upgrading a 2.2 kernel to a 2.4 kernel.


7.2.6 Parallel port support

For kernel-image-2.4.*, parallel port support is provided as a module. Enable it by:

     # modprobe lp
     # echo lp >> /etc/modules

See Documentation/parport.txt in the Linux source.


7.3 Tuning the kernel through the proc filesystem

The behavior of the Linux kernel can be changed on the fly using the proc filesystem.

For basic information on changing kernel parameters through the /proc filesystem, read Documentation/sysctl/* in the Linux source.

See some examples of kernel parameter manipulations in /etc/init.d/networking and Strange access problems with some websites, Section 3.7.5.

See sysctl.conf(5) for how to set up the boot time kernel configuration through /proc filesystem with /etc/init.d/procps.sh script usually run from /etc/rcS.d/S30procps.sh.


7.3.1 Too many open files

The Linux kernel may complain "Too many open files". This is due to the small default value (8096) for file-max. To fix this problem, run the following command as root:

     # echo "65536"  > /proc/sys/fs/file-max  # for 2.2 and 2.4 kernel
     # echo "131072" > /proc/sys/fs/inode-max # for 2.2 kernel only

or put the following into /etc/sysctl.conf for the permanent change:

     file-max=65536   # for 2.2 and 2.4 kernel
     inode-max=131072 # for 2.2 kernel only

7.3.2 Disk flush intervals

You can change disk flush intervals through the proc filesystem. The following will shorten its interval from the default five seconds to one second.

     # echo "40 0 0 0 100 30000 60 0 0"  > /proc/sys/vm/bdflush

This may negatively impact file I/O performance a little bit. But this secures file contents except for the last one second which is shorter than the default five seconds. This is true even for journaling filesystems.


7.3.3 Sluggish old low memory machines

For some old low memory systems, it may still be useful to enable over-commit of memory through the proc filesystem:

     # echo 1 > /proc/sys/vm/overcommit_memory

7.4 The 2.6 kernel with udev

The udev is a dynamic replacement for /dev/. Device names can be chosen to be very short ones. The devfs used in the 2.4 kernel is now obsolete.

Installing the new Debian 2.6 kernel provided by kernel-image-2.6.NN with udev package will enable this.


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ A ] [ next ]

Debian Reference

CVS, Mon Apr 3 22:57:03 UTC 2005

Osamu Aoki osamu@debian.org
Editor: David Sewell dsewell@virginia.edu
Authors, Section A.1