February 25, 2005

Linux Remote Serial Console Howto - notes

LDP: Remote Serial Console Howto

Env:
OS -- Red Hat Linux 9, Fedora Core 2
boot loader -- GRUB

Modify steps:
1. GRUB parameter:

bash# vi /etc/grub.conf
Add below 2 lines to set the serial console as 9600/8/n/1, and 10 secs timeout.
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=10 -dumb serial console
Add a single user mode option to GRUB menu
title Red Hat Linux (2.4.9-21) single user mode
lock
root (hd0,0)
kernel /vmlinuz-2.4.9-21 ro root=/dev/hda6 s
initrd /initrd-2.4.9-21.img
2. Kernel parameter in GRUB
Add the kernel parameter for serial console
title Red Hat Linux (2.4.9-21)
root (hd0,0)
kernel /vmlinuz-2.4.9-21 ro root=/dev/hda6 console=tty0 console=ttyS0,9600n8
initrd /initrd-2.4.9-21.img
3. Install mgetty
The mingetty which was installed can not use for serial console.
Please get mgetty and install it.

4. Add mgetty as ttyS in /etc/inittab
co:2345:respawn:/sbin/mgetty ttyS
5. Configure /etc/mgetty+sendfax/mgetty.config for ttyS0
port ttyS0
speed 9600
direct yes
data-only yes
toggle-dtr yes
need-dsr yes
port-owner root
port-group root
port-mode 600
login-prompt @ \P login:\040
login-time 60
term vt102
6. Remove mingetty entry from /etc/inittab
1:2345:respawn:/sbin/mingetty tty1
# Additional virtual terminals are not used
2:2345:off:/sbin/mingetty tty2
3:2345:off:/sbin/mingetty tty3
4:2345:off:/sbin/mingetty tty4
5:2345:off:/sbin/mingetty tty5
6:2345:off:/sbin/mingetty tty6
Then restart init
bash# telinit q
7. Edit /etc/securetty to allow root login from serial console
add 'ttyS0' in /etc/securetty

8. Change init level to textual ( run level 3)
bash# vi /etc/inittab
find
id:5:initdefault:
edit as
id:3:initdefault:
9. Remove saved console setting
bash# rm -f /etc/ioctl.save
10. Alter target of /dev/systty
bash# cd /etc/makedev.d
bash# fgrep systty *
linux-2.4.x:l systty tty0
bash# vi linux-2.4.x
find
l systty tty0
edit as
l systty ttyS0
save it, then re-create /dev/systty
bash# cd /dev
bash# rm systty
bash# ./MAKEDEV systty
11. PAM configure
bash# vi /etc/security/console.perms
Add sconsole =ttyS0
Then modify the remaining entries from console to sconsole

12. Configure Red Hat Linux

bash# vi /etc/sysconfig/init

set it as:

BOOTUP=serial
PROMPT=no

bash# vi /etc/sysconfig/kudzu

set it as:
SAFE=yes

Then you can reboot and test it.

1 意見:

Jaki said...

補充 LILO 的修改:

LILO boot loader sample configuration:

serial=0,9600n8
timeout=100
restricted
password=PASSWORD


The password should be good, as it can be used to gain root access.
The LILO password is stored in plain text in the configuration file, so it should never be the same as any other password. The permissions on the configuration file should be set so that only root can read /etc/lilo.conf.

bash# chmod u=rw,go= /etc/lilo.conf

LILO has an option to display a boot message. This does not work with serial consoles. Remove any lines like:

message=/boot/message

LILO is now configured to use the serial console.

For each image entry in /etc/lilo.conf add the line:

append="console=tty0 console=ttyS0,9600n8"

Sometimes the append line will already exist. For example

append="mem=1024M"

In this case, the existing append line is modified to pass all the parameters. The result is:

append="mem=1024M console=tty0 console=ttyS0,9600n8"

Now that we have finished configuring LILO, use the lilo command to install the new boot record onto the disk:

bash# chown root:root /etc/lilo.conf
bash# chmod u=rw,g=,o= /etc/lilo.conf
bash# lilo
Added linux *