El kernel

Por Paco Aldarias Raya

Impreso: 23 de mayo 2007

Email: pacolinux arroba inicia punto es

Web: http://aldarias.es/pacodebian

Con Linux Debian. En Valencia (España)

El documento tiene version .html, y .pdf, cambiando en el navegador la parte final podrás acceder a ambos.

Este documento es de libre reproducción siempre que se cite su fuente.

Realizado con: LATEX

Índice General

1 Introducción

El núcleo o kernel es el corazón de linux.

Recomendable leer el Kernel Como:
http://es.tldp.org/COMO-INSFLUG/COMOs/Kernel-Como/Kernel-Como.html

2 Funciones

Las funciones mas importantes del mismo, aunque no las unicas, son:
  1. Administracion de la memoria, para todos los programas en ejecucion.
  2. Administracion del tiempo de procesador, que estos programas en ejecucion utilizan.
  3. Es el encargado de que podamos acceder a los perifericos/elementos de nuestro ordenador de una manera comoda.

3 Compilación

Estos pasos son indicados en el fichero REAME del kernel q nos bajamos, el cual se puede leer una vez descomprimido.

Los pasos son:

  1. Bajarse el nucleo
    Se puede bajar el último nucleo desde:
    http://www.linux-es.com/kernel.php
    http://www.kernel.org
    Actualmente la última versión estabale es el 2.4.20, aunque debian woody traer la 2.4.18

    Nota: En el aula podemos cogerlo desde donde diga el profesor y guardarlo en la carpeta del usuario.

  2. Descomprimirlo
    Movemos el fichero a la carpeta /usr/src/:

    #mv /home/usuario/linux-2.4.20.tar.bz2 /usr/src/

    Nos cambiamos a la carpeta /usr/src/:

    #cd /usr/src/

  3. Instalar bzip2, para descomprimir:

    #apt-get install bzip2

  4. Descomprimimos:

    #tar jxvf linux-2.4.20.tar.bz2

  5. Para poder ejecutar make menuconfig, hay q instalar los paquetes:
    #apt-get install make gcc ncurses-bin libncurses5-dev

    Para poder ejecutar make xconfig (qt interface), hay q instalar:
    #apt-get install libqt3-dev make gcc bin86 libc6-dev kernel-package module-init-tools

    Para poder ejecutar make gconfig (gtk interface de gnome), hay q instalar:
    # apt-get install libglade2-dev make gcc bin86 libc6-dev kernel-package module-init-tools

  6. Pasarse a la carpeta /usr/src/linux-2.4.20/
    # cd /usr/src/linux-2.4.20/

  7. Coger la configuración del nucleo antigua:

    # make oldconfig

    Al salir nos crea un fichero .config

    Al terminar haremos una copia para no perderla:
    cp .config .config-oldconfig

  8. Configurar el núcleo
    # make menuconfig
    Al salir guardando nos crea un fichero .config

  9. Compilarlo (esta versión para el kernel con módulos)
    #make dep
    #make bzImage
    #make modules
    #make modules_install

  10. Ponemos el núcleo bzImage en /boot/
    #cp /usr/src/linux-2.4.20/arch/i386/boot/bzImage /boot/linux2420

  11. Cambiar el lilo
    #nano /etc/lilo.conf

    Anadir esto:

    image=/boot/linux2420
    label=Linux2420
    read-only

  12. Actualizar el arranque
    #lilo -v

  13. Reiniciar el ordenador

  14. Ejecutar para resolver las dependencias: #depmod -a

4 Configurar el kernel: Make menuconfig

Permite sacar un menu con todas las opciones del kernel que queremos. Es equivalente poner:
make config
make menuconfig
make xconfig

Make menuconfig es el recomendable, y para poder usarlo hay q instalar los paquetes:
make gcc, ncurses-bin libncurses5-dev

Figura 1: Make menuconfig
Image makemenu

Empecemos el proceso.

Ir a la carpeta donde esta el núcleo descomprimido

#cd /usr/src/linux-2.4.20

Leer la ayuda q viene:

#less README

Leer mas documentación:

#ll /usr/src/linux-2.4.19/Documentation/

Ejecutarlo:

# make menuconfig

Es importante coger la cpu q tenermos en la opción: Processor Type

Nos genera un fichero llamado .config, donde se guarda lo que hayamos introducido Es bueno hacer una copoia de este fichero por si tenemos q volver a la situación anterior.

5 Ver el log del kernel

# dmesg Nos informa de las opciones cargadas

6 Mas documentación

Hacer make psdocs o make pdfdocs o make htmldocs y mira en el directorio Documentation

7 Otra forma de compilar

Ahi una manera la mar de facil para recompilar el kernel en debian,

------Copipasteo de una receta de la espiral -------

1º Instalar:
kernel-package kernel-source-2.4.3
kernel-doc-2.4.3 fakeroot tcl8.2-dev tk8.2-dev.

2º Desempaquetamos:

 /usr/src/
tar xvIf /usr/src/kernel-source-2.4.3.tar.bz2
ln -s kernel-source-2.4.3 linux
cd linux/

3 Arrancamos la herramienta gráfica de configuración:

make xconfig

Recuerdo que es mejor entrar como superusuario con

ssh root@localhost

4 Compilamos:

make-kpkg cleantime make-kpkg --revision=mio1 kernel_image

5  Instalamos:

dpkg --install /usr/src/kernel-image-2.4.3_mio1_i386.deb

6  Ajustamos el arranque para permitir el arranque de los dos kernel:
el antiguo por si hay problemas, y el nuevo. El /etc/lilo.conf debería parecerse a:

boot=/dev/hda
compact
vga=ext
prompt
timeout=300
default=linux

image=/vmlinuz
    root=/dev/hda2
    label=linux
    read-only

image=/boot/vmlinuz-2.2.19pre17
    root=/dev/hda2
    label=linux-old
    read-only

other=/dev/hda1
    label=win

7 Ejecutamos:

lilo

y reiniciamos con el nuevo kernel.

8 Otra forma de tener el nuevo kernel

Teniendo debian 3.o y no me iba el sonido. El soporte para AC97 lo puedes tener de la siguiente forma. Lo primero es bajarte el ultimo kernel ya compilado para debian.

#apt get install kernel-image-2.4.18-686 (en el caso de que tengas un 686)

#apt get install kernel-headers-2.4.18-686 (lo mismo de antes)

luego te vas a /usr/src y haces un enlace simbólico a la carpeta /usr/src/linux (si no la tienes la creas)

#ln -s /usr/src/kernel-headers-2.4.18-686 /usr/src/linux

Una vez hecho eso y configurado el lilo para que te cargue ese kernel (si no sabes cómo dimelo y te lo explico). Una vez arrancado el nuevo kernel (compruebalo con uname -a) haces

#modconf

y alli ya encontrarás para cargar en el kernel el módulo de la ac97

9 Hacer que ordenador se apage

General setup
<*>   Advanced Power Management BIOS support
Ignore USER SUSPEND
[*]     Enable PM at boot time
Make CPU Idle calls when idle
Enable console blanking using APM
RTC stores time in GMT
[*]     Allow interrupts during APM BIOS calls
[*]     Use real mode APM BIOS call to power off

Notas:

  1. Fijate bien las especificaciones de tu placa. Si es ACPI compila el kernel con soporte para acpi y NO para apm.

  2. Si no se apaga añadir en /etc/lilo.conf
    append="apm=power-off"
    

10 Configurar el kernel para que soporte iptables

Ejemplo para 2.4.20 kernel

Code maturity level options  --->
     [*] Prompt for development and/or incomplete code/drivers

 
Networking options --->
     [*] Network packets filtering (replace ipchains)

 
Networking options ---> 
     IP: Netfilter Configuration --->
          <M> Connection tracking (required for masq/NAT)
          <M>   FTP protocol support                    
          <M>   IRC protocol support                   
          <M> IP tables support (required for filtering/masq/NAT)
          <M>   limit match support                             
          <M>   MAC address match support                      
          <M>   Packet type match support                    
          <M>   netfilter MARK match support                
          <M>   Multiple port match support                
          <M>   TOS match support                         
          <M>   LENGTH match support                     
          <M>   TTL match support                      
          <M>   tcpmss match support                  
          <M>   Connection state match support      
          <M>   Connection tracking match support  
          <M>   Unclean match support (EXPERIMENTAL)      
          <M>   Packet filtering                        
          <M>     REJECT target support                
          <M>   Full NAT                              
          <M>     MASQUERADE target support          
          <M>     REDIRECT target support           
          <M>   Packet mangling                    
          <M>     TOS target support              
          <M>     MARK target support          
          <M>   LOG target support           
          <M>   TCPMSS target support

11 Conficurar el kernel para grabadora pci

IDE, ATA and ATAPI Block devices
<*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
<*>   SCSI emulation support
< >   Include IDE/ATAPI CDROM support
<*>   SCSI emulation support

SCSI support
<*> SCSI support
<*>   SCSI CD-ROM support
   [*]     Enable vendor-specific extensions (for SCSI CDROM) (NEW)
<*>   SCSI generic support

Block devices
<M> Loopback device support
Más información en: grabadora.html

12 Configuración de mi kernel

Vamos a ver q eligo con make menuconfig con kernel 2.4.20:

12.1 Code maturity level options

 Prompt for development and/or incomplete code/drivers

12.2 Loadable module support

[*] Enable loadable module support
[*]   Set version information on all module symbols
[*]   Kernel module loader

12.3 Processor type and features

(K6/K6-II/K6-III) Processor family
[*] Machine Check Exception
< > Toshiba Laptop support
< > Dell laptop support
< > /dev/cpu/microcode - Intel IA32 CPU microcode support
<M> /dev/cpu/*/msr - Model-specific register support
<M> /dev/cpu/*/cpuid - CPU information support
(off) High Memory Support
Math emulation
MTRR (Memory Type Range Register) support
Symmetric multi-processing support
[*] Local APIC support on uniprocessors
IO-APIC support on uniprocessors
Unsynced TSC support

12.4 General setup

[*] Networking support
[*] PCI support
(Any)   PCI access mode
ISA bus support
[*] PCI device name database
EISA support
MCA support
[*] Support for hot-pluggable devices
PCMCIA/CardBus support  --->
PCI Hotplug Support  --->
[*] System V IPC
 BSD Process Accounting
[*] Sysctl support
(ELF) Kernel core (/proc/kcore) format
<*> Kernel support for a.out binaries
<*> Kernel support for ELF binaries
<*> Kernel support for MISC binaries
[*] Power Management support
<*>   Advanced Power Management BIOS support
[ ] Ignore USER SUSPEND
[*]    Enable PM at boot time
[ ] Make CPU Idle calls when idle
[ ] Enable console blanking using APM
[ ] RTC stores time in GMT
[*]     Allow interrupts during APM BIOS calls
[*]     Use real mode APM BIOS call to power off

12.5 Memory Technology Devices (MTD)

< > Memory Technology Device (MTD) support

12.6 Paralle Parallel port support

<M>   PC-style hardware
<M>     Multi-IO cards (parallel and serial)
< >     Support for PCMCIA management for PC-style ports
[ ] Support foreign hardware
[*]   IEEE 1284 transfer modesl port support

12.7 Plug and Play configuration

<*> Plug and Play support
<*>   ISA Plug and Play support

12.8 Block devices

<*> Normal floppy disk support
< > Parallel port IDE device support
< > Compaq SMART2 support
< > Compaq Smart Array 5xxx support
< > Mylex DAC960/DAC1100 PCI RAID Controller support
<M> Loopback device support
<M> Network block device support
<M> RAM disk support
(4096)   Default RAM disk size
 Per partition statistics in /proc/partitions

12.9 Multi-device support (RAID and LVM)

 Multiple devices driver support (RAID and LVM)

12.10 Networking options

<*> Packet socket
[ ] Packet socket: mmapped IO
<M> Netlink device emulation
[*] Network packet filtering (replaces ipchains)
[*]   Network packet filtering debugging
[*] Socket Filtering
<M> Unix domain sockets
[*] TCP/IP networking
[*]   IP: multicasting
[*]   IP: advanced router
[*]     IP: policy routing
[*]       IP: use netfilter MARK value as routing key
[*]       IP: fast network address translation
[*]     IP: equal cost multipath
[*]     IP: use TOS value as routing key
[*]     IP: verbose route monitoring
[*]     IP: large routing tables
[ ] IP: kernel level autoconfiguration
< >   IP: tunneling
<M>   IP: GRE tunnels over IP
[*]     IP: broadcast GRE over IP
[ ] IP: multicast routing
[*]   IP: TCP Explicit Congestion Notification support
[*]   IP: TCP syncookie support (disabled per default)
IP: Netfilter Configuration  --->
< > 802.1Q VLAN Support
---
< > The IPX protocol
< > Appletalk protocol support
Appletalk devices  --->
< > DECnet Support
< > 802.1d Ethernet Bridging
QoS and/or fair queueing  --->
Network testing  --->

IP: Netfilter Configuration
 <*> Connection tracking (required for masq/NAT)
<*>   FTP protocol support
<*>   IRC protocol support
<*> IP tables support (required for filtering/masq/NAT)
<*>   limit match support
<*>   MAC address match support
<*>   Packet type match support
<*>   netfilter MARK match support
<*>   Multiple port match support
<*>   TOS match support
<*>   ECN match support
<*>   DSCP match support
<*>   AH/ESP match support
<*>   LENGTH match support
<*>   TTL match support
<*>   tcpmss match support
<*>   Helper match support
<*>   Connection state match support
<*>   Connection tracking match support
<*>   Packet filtering
<*>     REJECT target support
<*>   Full NAT
<*>     MASQUERADE target support
<*>     REDIRECT target support
[*]     NAT of local connections (READ HELP)
<*>   Packet mangling
<*>     TOS target support

12.11 Character devices

[*] Virtual terminal
[*]   Support for console on virtual terminal
<*> Standard/generic (8250/16550 and compatible UARTs) serial support
[*]   Support for console on serial port
[ ] Extended dumb serial driver options
[ ] Non-standard serial port support
[*] Unix98 PTY support
(256) Maximum number of Unix98 PTYs in use (0-2048)
<M> Parallel printer support
[*]   Support for console on line printer
<M> Support for user-space parallel port device drivers

I2C support  --->
Mice  --->
Joysticks  --->
< > QIC-02 tape support

Watchdog Cards  --->
< > AMD 768 Random Number Generator support
< > Intel i8x0 Random Number Generator support
< > AMD 76x native power management (Experimental)
< > /dev/nvram support
< > Enhanced Real Time Clock Support
< > Double Talk PC internal speech card support
< > Siemens R3964 line discipline
< > Applicom intelligent fieldbus card support
Ftape, the floppy tape device driver  --->
<*> /dev/agpgart (AGP Support)
[ ] Intel 440LX/BX/GX and I815/I820/I830M/I830MP/I840/I845/I850/I860 support
[ ] Intel I810/I815/I830M (on-board) support
[*]   VIA chipset support
[ ] MD Irongate, 761, and 762 support
[ ] AMD 8151 support
[ ] Generic SiS support
[ ] ALI chipset support
[ ] Serverworks LE/HE support
[*] Direct Rendering Manager (XFree86 DRI support)
[*]   Build drivers for old (XFree 4.0) DRM
--- DRM 4.0 drivers
<*>   3dfx Banshee/Voodoo3+
< >   3dlabs GMX 2000
< >   ATI Rage 128
< >   ATI Radeon
< >   Intel I810
< >   Matrox G200/G400/G450

PCMCIA character devices  --->
< > ACP Modem (Mwave) support

12.12 Multimedia devices

<M> Video For Linux
Video For Linux  --->
Radio Adapters  --->

Video For Linux
[*]   V4L information in proc filesystem
< >   I2C on parallel port
--- Video Adapters
< >   Mediavision Pro Movie Studio Video For Linux
< >   Quickcam BW Video For Linux
< >   W9966CF Webcam (FlyCam Supra and others) Video For Linux
< >   CPiA Video For Linux
< >   SAA5249 Teletext processor
< >   SAB3036 tuner
< >   Zoran ZR36057/36060 Video For Linux
< >   Zoran ZR36120/36125 Video For Linux

13 File systems

[*] Quota support
<*> Kernel automounter support
<*> Kernel automounter version 4 support (also supports v3)
< > Reiserfs support
<*> Ext3 journalling file system support
[*]   JBD (ext3) debugging support
<*> DOS FAT fs support
<*> MSDOS fs support
< >  UMSDOS: Unix-like file system on top of standard MSDOS fs
<M> VFAT (Windows-95) fs support
<M> Compressed ROM file system support
[*] Virtual memory file system support (former shm fs)
<M> ISO 9660 CDROM file system support
[*]   Microsoft Joliet CDROM extensions
[*]   Transparent decompression extension
< > JFS filesystem support
< > Minix fs support
< > FreeVxFS file system support (VERITAS VxFS(TM) compatible)
< > NTFS file system support (read only)
< > OS/2 HPFS file system support
[*] /proc file system support
[*] /dev/pts file system for Unix98 PTYs
< > QNX4 file system support (read only)
<M> ROM file system support
<*> Second extended fs support
< > System V/Xenix/V7/Coherent file system support
< > UDF file system support (read only)
< > UFS file system support (read only)
Network File Systems  --->
Partition Types  --->
Native Language Support  --->

14 Native Language Support

<*> Codepage 437 (United States, Canada)
<*> NLS ISO 8859-1  (Latin 1; Western European Languages)
<*> NLS ISO 8859-15 (Latin 9; Western European Languages with Euro)

15 Kernel 2.6

15.1 Disco Duro

Donde en el kernel 2.6 que en el 2.4 es hdx y el 2.6 pasa a Scsi (sdx)

15.2 Para evitar la pantalla negra

Device Drivers> Graphics Support> 
 					[*] Support for frame buffer device
 					<*> VGA 16-colors graphics support
 					<*> VESA VGA Graphics support

 					  > Console display driver support

 						[*] Video mode selection support
 						[*] Framebuffer console support
 						[*]Select compiled-in support
 						      <*> VGA 8x8 fonts
 						      <*> VGA 8x16 fonts

16 Bibliografia

  1. Compiling a 2.6 kernel the Debian Way
    http://anarka.org/linux/debian_kernel.html

  2. Como actualizar al Kernel 2.6 . http://www.evolucionlinux.com/modules.php?name=News&file=article&sid=21

  3. Instalar kernel 2.6
    http://www.starlinux.net/forum/viewtopic.php?forum=21&showtopic=6630

17 Script de compilaciÃ^3: comp.sh

Como root

nano /usr/src/linux/comp.sh

kernel="2.6.20.7a"
destino="/media/hda6/linuxconf/kernel/"
cp ./comp.sh $destino
cp ./.config $destino"config"$kernel$(date +%Y-%m-%d-%H-%M)

make
make modules_install
depmod -a
cp arch/i386/boot/bzImage /boot/bzImage-$kernel
grub-install /dev/hda

Índice de Materias

Sobre este documento...

El kernel

This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.71)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html kernel -split 0 -local_icons 1 -show_section_numbers -no_auto_link -no_navigation

The translation was initiated by Paco on 2007-05-23


Paco 2007-05-23