Para tener la consola por el puerto serie habilitada en Linux (consola en ttyS0), debemos modificar los siguientes ficheros, o crearlos si alguno no existiera (si os sirve de orientación, nosotros los teníamos todos disponibles en un Linux Slackwaare 12.1 parcheado con Xenomai, con kernel 2.6.30.8 y boot loader LILO):

  • /etc/lilo.conf:

Hay que añadir en el APPEND de la configuración global:

APPEND = "console=tty0 console=ttyS0,115200n8"

si hay tarjeta gráfica, o si no la hay ni la habrá, basta con:

APPEND = "console=ttyS0,115200n8"

Como orientación, mostramos nuestro fichero lilo.conf modificado, donde subrayamos las líneas que hemos modificado:

# LILO configuration file
# generated by 'liloconfig'
#
# Start LILO global section
# Append any additional kernel parameters:
# Append=" vt.default_utf8=0 ide-core.nodma=0.0"
Append="console=tty0 console=ttyS0,115200n8 ide-core.nodma=0.0"
boot = /dev/hda
install=text

# Standard menu.
# Or, you can comment out the bitmap menu above and
# use a boot message with the standard menu:
message = /boot/boot_message.txt

# Wait until the timeout to boot (if commented out, boot the
# first entry immediately):
prompt
default = 1

# Timeout before the first entry boots.
# This is given in tenths of a second, so 600 for every minute:
timeout = 300

# Override dangerous defaults that rewrite the partition table:
change-rules
reset

# Normal VGA console
vga = normal
# VESA framebuffer console @ 1024x768x64k
# vga=791
# VESA framebuffer console @ 1024x768x32k
# vga=790
# VESA framebuffer console @ 1024x768x256
# vga=773
# VESA framebuffer console @ 800x600x64k
# vga=788
# VESA framebuffer console @ 800x600x32k
# vga=787
# VESA framebuffer console @ 800x600x256
# vga=771
# VESA framebuffer console @ 640x480x64k
# vga=785
# VESA framebuffer console @ 640x480x32k
# vga=784
# VESA framebuffer console @ 640x480x256
# vga=769
# End LILO global section

# Linux bootable partition config begins
image = /boot/vmlinuz
root = /dev/hda1
label = 1
read-only

image = /boot/vmlinuz-huge-2.6.29.6
root = /dev/hda1
label = 2
read-only
# Linux bootable partition config ends

Observad que hemos indicado 'install=text' frente al 'install=menu' que pudiera existir, con lo que debemos eliminar o comentar todas las líneas que se refieran a mapas de bits (bitmaps, o bmp), ya que si las dejamos LILO se quejará indicándonos que no es compatible la opción gráfica con 'install=text'. Esto es debido a que la consola remota no acepta entornos gráficos ni imágenes, sólo acepta texto.

¡Recordad que tras modificar lilo.conf siempre hay que teclear "lilo" en el shell para actualizar el boot loader o los cambios no tendrán efecto!

$ lilo

  • /etc/inittab:

En este fichero hay que descomentar (o añadir, depende del caso) las siguientes líneas:

# Local serial lines:
s1:12345:respawn:/sbin/agetty -L ttyS0 115200 vt100

Con esta línea decimos que en los runlevels 1, 2, 3, 4 y 5, relance el comando 'agetty -L ttyS0 115200 vt100'. agetty, al igual que getty, ugetty y otros similares, lo que hace es lanzar el prompt de login por la interfaz indicada (ttyS0, puerto serie COM1 en Windows), a la velocidad indicada (115200 bps) y con el tipeado de datos del terminal indicado (vt100).

Gracias a esta línea, aunque nuestra BIOS no permita mostrar nada en el arranque por el puerto serie, se nos mostrará, tras la carga del Sistema Operativo, la invitación para hacer login, lo cual nos habilita para iniciar sesión en nuestro equipo remoto a través del puerto serie. ¿No es maravilloso?

Mostramos a continuación nuestro fichero inittab completo para quien le sirva:

#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
# Version: @(#)inittab 2.04 17/05/93 MvS
# 2.10 02/10/95 PV
# 3.00 02/06/1999 PV
# 4.00 04/10/2002 PV
#
# Author: Miquel van Smoorenburg, <Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo.>
# Modified by: Patrick J. Volkerding, <Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo.>
#

# These are the default runlevels in Slackware:
# 0 = halt
# 1 = single user mode
# 2 = unused (but configured the same as runlevel 3)
# 3 = multiuser mode (default Slackware runlevel)
# 4 = X11 with KDM/GDM/XDM (session managers)
# 5 = unused (but configured the same as runlevel 3)
# 6 = reboot

# Default runlevel. (Do not set to 0 or 6)
id:3:initdefault:

# System initialization (runs when system boots).
si:S:sysinit:/etc/rc.d/rc.S

# Script to run when going single user (runlevel 1).
su:1S:wait:/etc/rc.d/rc.K

# Script to run when going multi user.
rc:2345:wait:/etc/rc.d/rc.M

# What to do at the "Three Finger Salute".
ca::ctrlaltdel:/sbin/shutdown -t5 -r now

# Runlevel 0 halts the system.
l0:0:wait:/etc/rc.d/rc.0

# Runlevel 6 reboots the system.
l6:6:wait:/etc/rc.d/rc.6

# What to do when power fails.
pf::powerfail:/sbin/genpowerfail start

# If power is back, cancel the running shutdown.
pg::powerokwait:/sbin/genpowerfail stop

# These are the standard console login getties in multiuser mode:
c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c2:1235:respawn:/sbin/agetty 38400 tty2 linux
c3:1235:respawn:/sbin/agetty 38400 tty3 linux
c4:1235:respawn:/sbin/agetty 38400 tty4 linux
c5:1235:respawn:/sbin/agetty 38400 tty5 linux
c6:12345:respawn:/sbin/agetty 38400 tty6 linux

# Local serial lines:
s1:12345:respawn:/sbin/agetty -L ttyS0 115200 vt100
#s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100

# Dialup lines:
#d1:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS0 vt100
#d2:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS1 vt100

# Runlevel 4 used to be for an X window only system, until we discovered
# that it throws init into a loop that keeps your load avg at least 1 all
# the time. Thus, there is now one getty opened on tty6. Hopefully no one
# will notice. ;^)
# It might not be bad to have one text console anyway, in case something
# happens to X.
x1:4:respawn:/etc/rc.d/rc.4

# End of /etc/inittab

Por último, indicar que si se quiere reiniciar el fichero inittab sin reiniciar el equipo, basta con poner en un terminal:

$ init q

  • /etc/securetty:

Con este fichero, permitimos el login al usuario root a través del puerto serie.Si se quiere, no hace falta modificarlo, porque nos podemos loguear como un usuario normal y, luego, una vez estemos dentro, loguearnos como root.

Mostramos a continuación nuestro fichero securetty para que lo podáis copiar si no lo teníais en vuestra máquina. Nosotros sólo tuvimos que descomentar (borrar la almohadilla) en la línea de ttyS0, ya que lo demás lo dejamos igual:

# This file defines which devices root can log in on.

# These are the ttys on the physical console:
console
tty1
tty2
tty3
tty4
tty5
tty6

# These are some remote ttys, and uncommenting them might be less than fully secure:
ttyS0
#ttyS1
#ttyS2
#ttyS3
#ttyp0
#ttyp1
#ttyp2
#ttyp3
#ttyp4
#ttyp5
#ttyp6
#ttyp7
#pts/0
#pts/1
#pts/2
#pts/3
#pts/4
#pts/5
#pts/6
#pts/7

  • /boot/boot_message.txt:

Este fichero es, simplemente, para rizar el rizo. Si vuestra arquitectura permite el arranque por puerto serie y habéis seleccionado 'install=text' en el fichero /etc/lilo.conf, podéis optar a mostrar un mensaje de texto personalizado en el arranque que os permita elegir entre los distintos Sistemas Operativos que tengáis instalados. Como nosotros tenemos dos kernels -uno de tiempo real y otro normal-, creamos el siguiente mensaje (con 'vim /boot/boot_message.txt' por ejemplo):

Bienvenido al arrancador LILO:

Por favor, teclee el numero de la opción que desee cargar
de las mostradas abajo y pulse [ENTER]. Las opciones son:

1 - Linux-2.6.30.8
2 - Linux-2.6.29.6

Una vez creado, le decimos a LILO dónde se encuentra este fichero, añadiendo la línea siguiente:

message = /boot/boot_message.txt

Tras esto, y como ya sabéis, hacemos:

$ lilo

para actualizarlo y habilitar los cambios que hemos hecho.

Y esto es todo. Con esta última modificación ya tenemos todo lo necesario para hacer un logueado a través del puerto serie en un sistema remoto. Pero, ¿con qué programa veo lo que me devuelva el sistema remoto? No te preocupes, en la última página te solucionamos esta duda.