Debian has its own method of recompiling the kernel and related modules. See also Debian и ядро, раздел 2.7.
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:
/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
.
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 my 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)
.
Get pristine sources from:
http://www.kernel.org/
http://pcmcia-cs.sourceforge.net/
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 ...
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
.
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, раздел 9.4.2.
See Documentation/*.txt
in the Linux source for the precise
information.
/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, раздел 10.10.5.
[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.
/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.
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).
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.
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.
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,
раздел 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
.
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
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.
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
Справочник по Debian
CVS, Пон 3. Апр 2005, 22:59:13 UTCosamu@debian.org
dsewell@virginia.edu