HPUNIX Сайт о ОС и не только!

Глава Семь - The Linux kernel under Debian

8 апреля 2009 - unix
Глава Семь - The Linux kernel under Debian

Debian has its own method of recompiling the kernel and related modules. See also Debian и ядро, раздел 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 pat/hdbk/.

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 ma/hdbk/ine. 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

Wat/hdbk/ 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.

  1. # apt-get install debhelper modutils kernel-package libncurses5-dev
  2. # apt-get install kernel-source-2.4.18 # use latest version
  3. # apt-get install fakeroot
  4. # vi /etc/kernel-pkg.conf # input my name and email
  5. $ cd /usr/src # build directory
  6. $ tar --bzip2 -xvf kernel-source-2.4.18.tar.bz2
  7. $ cd kernel-source-2.4.18 # if this is your kernel source
  8. $ cp /boot/config-2.4.18-386 .config # get current config as default
  9. $ make menuconfig # customize as one wishes
  10. $ make-kpkg clean # mustn (per: man make-kpkg)
  11. $ fakeroot make-kpkg --append_to_version -486 --initrd \
  12. --revision=rev.01 kernel_image \
  13. modules_image # modules_image is for pcmcia-cs* etc.
  14. $ cd ..
  15. # 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., un/hdbk/eck the box).

Глава Семь - The Linux kernel under Debian

On an SMP ma/hdbk/ine, set CONCURRENCY_LEVEL according to kernel-pkg.conf(5).

7.1.2 Classic method

Get pristine sources from:

  • Linux: http://www.kernel.org/

  • pcmcia-cs: http://pcmcia-cs.sourceforge.net/

    Глава Семь - The Linux kernel under Debian

or use equivalent sources in Debian and do the following:

  1. # cd /usr/src
  2. # tar xfvz linux-whatever.tar.gz
  3. # rm -rf linux
  4. # ln -s linux-whatever linux
  5. # tar xfvz pcmcia-cs-whatever.tar.gz
  6. # ln -s pcmcia-cs-whatever pcmcia
  7. # cd linux
  8. # make menuconfig
  9. ... configure stuff ...
  10. # make dep
  11. # make bzImage
  12. ... edits for lilo / b ...
  13. ... move /usr/src/linux/ar/hdbk//i386/boot/bzImage to boot ...

  14. ... /sbin/lilo or whatever you do for b
  15. # make modules; make modules_install
  16. # cd ../pcmcia
  17. # make config
  18. # make all
  19. # make install
  20. ... add needed module names to /etc/modules
  21. # shutdown -r now
  22. ... 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 whi/hdbk/ glibc was built, whi/hdbk/ 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 Linux kernel under Debian
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 su/hdbk/ as discover. See also Hardware detection for X, раздел 9.4.2.

See 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:

  1. # ISA PnP driver
  2. isa-pnp
  3. # New Low level PCMCIA driver
  4. # 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:

Глава Семь - The Linux kernel under Debian

"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.


See Linux PCMCIA HOWTO and Network configuration and PCMCIA, раздел 10.10.5.

7.2.2 SCSI

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

  1. # SCSI core
  2. scsi_mod
  3. # SCSI generic driver
  4. sg
  5. # SCSI disk
  6. sd_mod
  7. # All other needed HW modules
  8. ...

depmod may take care of some of the above modules.

7.2.3 Network function

Глава Семь - The Linux kernel under Debian

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

  1. # net/ipv-4
  2. ip_gre
  3. ipip
  5. # net/ipv-4/netfilter
  6. # iptable (in order)
  7. ip_tables
  8. ip_conntrack
  9. ip_conntrack_ftp
  10. iptable_nat
  11. iptable_filter
  12. iptable_mangle
  13. #
  14. ip_nat_ftp
  15. ip_queue
  16. #
  17. ipt_LOG
  18. ipt_MARK
  19. ipt_MASQUERADE
  20. ipt_MIRROR
  21. ipt_REDIRECT
  22. ipt_REJECT
  23. ipt_TCPMSS
  24. ipt_TOS
  25. ipt_limit
  26. ipt_mac
  27. ipt_mark
  28. ipt_multiport
  29. ipt_owner
  30. ipt_state
  31. ipt_tcpmss
  32. ipt_tos
  33. ipt_unclean
  34. #
  35. #ip/hdbk/ains
  36. #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:

  1. # cd /etc; mv fstab fstab.old
  2. # sed 's/ext2/ext3,ext2/g' <fstab.old >fstab
  3. # vi /etc/fstab
  4. ... set root filesystem type to "auto" instead of "ext3,ext2"
  5. # cd /etc/mkinitrd
  6. # e/hdbk/o jbd >>modules
  7. # e/hdbk/o ext3 >>modules
  8. # e/hdbk/o ext2 >>modules
  9. # cd /
  10. # apt-get update; apt-get install kernel-image-2.4.17-686-smp
  11. ... install latest kernel and set up boot (lilo isn here)
  12. # tune2fs -j -i Нуль /dev/hda1
  13. # tune2fs -j -i Нуль /dev/hda2
  14. ... For all EXT2 FS's converted to EXT3
  15. # 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:

  1. # mkinitrd -o /boot/initrd.img-2.4.17-686-smp /lib/modules/2.4.17-686-smp
  2. # lilo
  3. # tune2fs -j -i Нуль /dev/hda1
  4. # tune2fs -j -i Нуль /dev/hda2
  5. ... for all EXT2 FS's converted to EXT3
  6. # shutdown -r now

Now EXT3 journaling is enabled.

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

  1. ... at initrd prompt to gain shell (5 sec.), type RETURN
  2. # insmod jbd
  3. # insmod ext3 # modprobe ext3 may take care of everything
  4. # insmod ext2
  5. # ^D
  6. ... 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

Глава Семь - The Linux kernel under Debian
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 /hdbk/ange 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:

  1. # modprobe lp
  2. # e/hdbk/o lp >> /etc/modules

See Documentation/parport.txt in the Linux source.

7.3 Tuning the kernel through the proc filesystem

Глава Семь - The Linux kernel under Debian
The behavior of the Linux kernel can be /hdbk/anged on the fly using the proc filesystem.

For basic information on /hdbk/anging 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 Странноватые трудности доступа на некие web-сайты, раздел 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 usuallyn 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:

  1. # e/hdbk/o "65536" > /proc/sys/fs/file-max # for 2.2 and 2.4 kernel
  2. # e/hdbk/o "131072" > /proc/sys/fs/inode-max # for 2.2 kernel only

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

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

7.3.2 Disk flush intervals

You can /hdbk/ange disk flush intervals through the proc filesystem.

The following will shorten its interval from the default five seconds to one second.

Building Linux Kernel

  1. # e/hdbk/o "40 Нуль 0 Нуль 100 30 тыщ 60 Нуль 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 whi/hdbk/ is shorter than the default five seconds.

This is e even for journaling filesystems.

7.3.3 Sluggish old low memory ma/hdbk/ines

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

  1. # e/hdbk/o Один > /proc/sys/vm/overcommit_memory


Osamu Aoki osamu#at#debian.org
Перевод Ильи В. Головко qref#at#yandex

Похожие статьи

  • Глава Восемь - Debian tips

    8.1 Booting the systemSee the LDP BootPrompt-HOWTOfor detailed information on the boot prompt. 8.1.1 "I forgot the root password!" (1)It is possible to boot a system and log on to the ro...

  • Глава Пятнадцать - Support for Debian

    The following resources provide help, advice, and support for Debian. Try your best to use self-help resources before crying out loud in the mailing lists. :) Note that you can access a lot of doc...

  • Глава 6 - Управление пакетами в Debian

    Эта глава основывается на более старенькой версии текста британского оригинала. Проверьте британский вариант тоже. Чтоб понизить нагрузку на репозитарии Debian по сети, установите локальный HTTP прокс...

  • Глава Три - Советы по установке системы Debian

    Официальная документация по установке Debian размещается по адресу http://www.debian.org/releases/stable/, и http://www.debian.org/releases/stable/installmanual. Версии документов, находящихся в...

  • Глава Четыре - Управление по Debian

    Эта секция поможет новеньким ориентироваться в мире Debian. Если Вы уже хотя бы незначительно использовали Unix-подобные операционные системы, то, возможно, знакомы со всем тем, о чем я тут пишу. Пожал...

Рейтинг: +9 Голосов: 219 1635 просмотров
Комментарии (0)

Нет комментариев. Ваш будет первым!

Найти на сайте: параметры поиска

Windows 7

Среда Windows 7 на первых порах кажется весьма непривычной для многих.

Windows 8

Если резюмировать все выступления Microsoft на конференции Build 2013.

Windows XP

Если Windows не может корректно завершить работу, в большинстве случаев это

Windows Vista

Если к вашему компьютеру подключено сразу несколько мониторов, и вы регулярно...