Linux Serial Console

All of the machines we have in our production environment are completely headless systems which makes sense since they are about 150 miles from where our main office is.

The beauty of a Sun Workstation is that, in following with the model of “The Network Is The Computer”, if there is no keyboard plugged in, the system directs all output via the serial port.  When I say “All”, I mean “all“.  So, if I want to shut down the machine (without physically powering it off), I can bring the system down to the “ok” prompt, which, for the Windows world, is the equivalent of being at the BIOS level.

Now that we have our first linux server in place, obviously we wanted to have “console” access to the machine.  However, one quickly realizes that with a PC-based system, the equivalent of the Sun based “console” is really not easily attainable.

One of the steps in the right direction is setting Linux up such that it directs its output via the serial console port.  This is helpful when you need to gain direct access to the system if the system goes off of the net for one reason or another (of course, you need a console server to provide you with access).

In Linux, it is actually pretty easy.  I emailed the general steps to a colleague of mine:

Here's the grub.conf file I created to output to both the serial console
and the primary video display.  The key lines are:
serial --unit=0 --speed=9600
terminal --timeout=2 serial console
And appending "console=tty0 console=ttyS0" to the kernel arguments.
Supposedly, the ordering of those arguments is important.  The last
argument is where single user mode and kernel messages are directed to,
so, in this case, the system will work with ttyS0 as if it were its
primary interface, and tty0 is then treated as a secondary interface. (I
found this buried in the following article:
http://www.rajeevnet.com/linux/grub_serial_console.html)

Also, I added the following line to /etc/inittab:
S0:12345:respawn:/sbin/mgetty -b -r -s 9600 -p "Login: " ttyS0

And I added "ttyS0" to the end of /etc/securetty.  That's supposed to
allow root to log in via the serial port.

With that done, I had (and still have) a serial console connection to
the headless linux box.

-Rich

~]# more /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/md1
#          initrd /initrd-version.img
#boot=/dev/md0
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
serial --unit=0 --speed=9600
terminal --timeout=2 serial console
title Fedora Core (2.6.17-1.2139_FC4)
root (hd0,0)
kernel /vmlinuz-2.6.17-1.2139_FC4 ro root=/dev/md1 rhgb quiet
console=tty0 console=ttyS0
initrd /initrd-2.6.17-1.2139_FC4.img
title Fedora Core (2.6.17-1.2141_FC4)
root (hd0,0)
kernel /vmlinuz-2.6.17-1.2141_FC4 ro root=/dev/md1 rhgb quiet
console=tty0 console=ttyS0
initrd /initrd-2.6.17-1.2141_FC4.img

How To Change The Hostname In Solaris

To change the hostname on a Solaris system, you should edit all of these files:

  • /etc/hosts
  • /etc/nodename
  • /etc/hostname.*
  • /etc/net/ticlts/hosts        (this file is unused in Solaris 10 and above)
  • /etc/net/ticots/hosts       (this file is unused in Solaris 10 and above)
  • /etc/net/ticotsord/hosts  (this file is unused in Solaris 10 and above)

You should then reboot the server to test your changes and ensure that they operate correctly.

Some say to update “/etc/inet/ipnodes”, but that only contains the information for “localhost” and does not need to have any changes made to it.