[CentOS] /etc/inittab: Serial access/ Console Server

Paul Heinlein heinlein at madboa.com
Fri Jun 30 16:58:11 UTC 2006


On Thu, 29 Jun 2006, Chris Fox wrote:

> > T0:23:respawn:/sbin/agetty 9600 ttyS0 vt100
> >
> > Not sure if it will work, but seems likely.
> >
> I've always wanted to know how this is done (before serial ports go 
> away forever).

Go away?!? Then computers would violate the fundamental law: "A real 
server needs only three cords to function: power, ethernet, and 
serial." :-)

At a former job when I was installing a lot of machines with serial 
consoles, I'd modify the bootloader directive in the kickstart file:

bootloader --location=mbr --append="console=tty0 console=ttyS0"

and use a stock shell routine in the %post section:

#
# serial_console_enable
#
# edit conf files so that /dev/console spews to /dev/ttySx
#
# usage:
#  serial_console_enable ttySx (where x is usually 0 or 1)
#
function serial_console_enable {

  echo "configuring for serial port on $1 ..."

  # 'p' is short for 'port'; test sanity of device name.
  local p=$( expr "$1" : 'ttyS\([[:digit:]]\)' )

  # bail if $p is empty
  if [ -z "$p" ]; then
    echo "unknown argument '$1' to serial_console_enable" >&2
    return
  fi

  echo "=> inittab"
  echo "con:2345:respawn:/sbin/agetty -h ttyS${p} 9600 vt100" >> /etc/inittab

  echo "=> securetty"
  echo "ttyS${p}" >> /etc/securetty

  echo "=> ioctl.save"
  rm -f /etc/ioctl.save

  echo "=> grub.conf"
  mv /boot/grub/grub.conf /boot/grub/grub.conf.orig
  cat <<__eof__ > /boot/grub/grub.conf
# added by kickstart
serial --unit=${p} --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=5 serial console
__eof__
  grep -v splashimage /boot/grub/grub.conf.orig >> /boot/grub/grub.conf
  echo

} # end serial_console_enable


-- 
Paul Heinlein <> heinlein at madboa.com <> www.madboa.com



More information about the CentOS mailing list