26 de març 2009

compilar kernel 2.6.29

Después del anuncio de ayer del tuz, al llegar a casa no me pude estar de probar de compilar el kernel 2.6.29 en mi debian squeeze.

Siempre que te pones a compilar un kernel sientes cierta emoción por el posible logro o un kernel panic que te impide a continuar, por suerte grub permite elegir con qué kernel iniciar tu sistema, por ejemplo, si no nos arranca el kernel nuevo, vamos a /boot/grub/menu.lst y borramos las lineas que cargan el kernel nuevo para que no lo cargue por defecto, además de borrar los ficheros initrd.img-numerokernel, System.map-numerokernel y vmlinuz-numerokernel de /boot. Sabiendo esto podemos estar tranquilos a la hora de compilar kernels, ya que es una acción facilmente reversible :)

Una de las pijaditas que he activado para este kernel es el framebuffer, para tener a un par de tuz guardianes al momento que arrancamos la máquina:

Aquí tenéis a mi sistema arrancando con el kernel 2.6.29 esta mañana :)

Para realizar la compilación he ido un poco a saco y he compilado directamente las sources que me he descargado de kernel.org

Así que vamos a empezar:

1. nos descargamos los sources de kernel.org, nos descargaremos el paquete full (F)
http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.29.tar.bz2

2. a continuación comprobamos que tenemos los siguientes paquetes instalados:

# apt-get install build-essential libncurses5 libncurses-dev
build-essential: para que podamos usar las herramientas de desarrollador que nos permitirán recompilar el kernel
libncurses5: lo vamos a necesitar para poder mostrar interfaces ncurses (make menuconfig)...

3. copiamos el fichero descargado de la página de kernel.org en /usr/src y lo descomprimimos
# tar xvjf linux-2.6.29.tar.bz2
4. a continuación realizamos los siguientes pasos

# ln -s linux-2.6.27 linux
# cd /boot
# cp config-2.6.26-1-686 config
este paso en mi caso no lo he realizado, ya que he querido probar si los sources que vienen de kernel.org son aptos para compilarlos en equipos con procesadores intel, tras ver el valor por defecto soporte para procesadores intel, tiene la pinta que el kernel 2.6.29 ya viene preparado con una configuración apta para el mayor numero de portátiles, así que este paso no lo he hecho y el sistema ha arrancado sin ningún problema :)

# cd /usr/src/linux
# make menuconfig
esto último nos va a cargar el menú ncurses con las entrañas del kernel, ahí vamos a encontrar soporte nativo de hardware en el nucleo de linux, podéis ir mirando, pero si no sabéis de qué van las cosas mejor no tocar o informarse antes ;)

una de las opciones que he activado es en drivers > graficos > logo inicial (o algo así), de esta forma nos aparece el logo inicial al arrancar el sistema (los 2 tuz, correspondientes al numero de procesadores que tiene mi maquina).

una vez modificado el kernel, salimos al menu principal y guardamos nuestro fichero de configuración, por costumbre le he puesto 2.6.27.1 correspondiente a la primera versión del fichero de configuración de mi kernel.

ahora ya sólo hace falta compilar y reconfigurar grub (en esta máquina aún uso grub legacy, pero usando los comandos que hay a continuación también tendría que funcionar para grub2). Os recomiendo mantener una copia de vuestro /boot/grub/menu.lst que funciona.
# make && make install && make modules_install && mkinitramfs -o /boot/initrd.img-2.6.29 2.6.29 && update-grub
reiniciamos, cruzamos los dedos, y esperamos que el kernel no nos suelte un kernel panic, si te ocurre esto, prueba de cargar el fichero config que tienes en /boot/ usando el make menuconfig y load an alternate config file.

3 comentaris:

Blackhold ha dit...

fran: KERNEEEEL!!!

Anònim ha dit...

a ver si para el proximo kernel que compile activo esa opcion :D

piscue ha dit...

también se puede hacer al estilo debian (make-kpkg):

http://www.debian-administration.org/articles/90

me gusta el detalle de la revisión:

"-revision number
Changes the Debian revision number for the packages produced to
the argument number. This has certain constraints: the --revi-
sion option only has an effect during the configure phase. So,
if you want to re-run make-kpkg with a different revision num-
ber, you have to make sure you start with a clean slate. Sec-
ondly, the version may contain only alphanumerics and the char-
acters ~ + . (tilde, full stop and plus) and must contain a
digit. (Look at the Policy manual for details). Optionally, you
may prepend the revision with a digit followed by a colon (:).
The default is 10.00.Custom unless the environment variable
DEBIAN_REVISION_MANDATORY is set, in which case an error is gen-
erated if the revision is not set on the command line or the
Policy for a new package. If the environment variable
IGNORE_UPPERCASE_VERSION is set, make-kpkg shall lower case ver-
sion numbers set in the Makefile or in the localversion file.
This option over rides the environment variable APPEND_TO_VER-
SION Please note that you must run a make-kpkg clean after
configuring the kernel using make (x|menu)?config, since that
creates the file include/linux/version.h without the
append_to_version data (foo). This file won't be updated by the
make-kpkg run (make-kpkg creates version.h if it doesn't exist,
but doesn't touch if exists), so the final kernel will _not_
have the append_to_version data in its version number it shall
look for the modules and symbols in all the wrong places. The
simplest solution is either to remove include/linux/version.h
after configuring and before compiling, or running make-kpkg
clean after configuring, before compiling. Note also that once
you use --append_to_version foo for configuring, or building the
kernel-image, you need to also use the same option in any later
invocation of make-kpkg (say, for building stand alone modules,
or something). make-kpkg does not remember the argument foo in
between invocations (this is different from the behavior of
--revision, which we do remember in between invocations). If you
are annoyed by make-kpkg whining about using --append_to_version
and there already being a version.h file from before, you can
set the environment variable VERSION_H_OK which shall shut off
the warning.
"

Publica un comentari a l'entrada