Console Output and Serial Terminals

From NST Wiki
Revision as of 07:58, 21 May 2011 by Rwh (talk | contribs) (Image:Warning.png‎ systemctl Bash Completion)
Jump to navigationJump to search

Overview

This page describes different methods for setting up a serial console post booting up an NST system. See Getting Started - Server Boot for setting up a serial console initially during a NST Live boot.


Serial Console On NST 2.13.0

Add Serial Console On Device: /dev/ttyS0

Use the following command to manually enable the serial console on NST versions 2.13.0 using upstart. This example will set the serial baud rate to: "57600" and use serial device: "/dev/ttyS0".

[root@probe ~]# initctl emit --no-wait fedora.serial-console-available ttyS0 57600
[root@probe ~]# 

A user login prompt should now be active on serial device: "/dev/ttyS0".


Serial Console On NST 2.15.0 or Above

Warning.png systemctl Bash Completion

The bash shell's completion function can be extended to external programs. The systemd-units RPM package contains a bash completion script ("/etc/bash_completion.d/systemctl-bash-completion.sh") for the systemctl command. Bash completion extension for the systemctl command can be quite useful for its long command argument's naming. To enable it, source it in within your bash shell:

[root@probe ~]# . /etc/bash_completion.d/systemctl-bash-completion.sh
[root@probe ~]# 

To use it, lets say to get the status of a serial device (systemctl status serial-getty@ttyS0.service), perform the following:

systemctl stat<tab>

Substitute the "<tab>" for the tab key. This will result in:

systemctl status

Now the next part of the command:

systemctl status seria<tab>

Again substitute the "<tab>" for the tab key. This will result in the full command:

systemctl status serial-getty@ttyS0.service

***Note: If more than one completion value is found, then hitting the tab key will not complete and fill in a value. In this case one may use the <esc> + = key sequence (i.e., The Escape key followed by the Equal Sign key) to find out the possible completion values.

Add Serial Console On Device: /dev/ttyS0

Use the following command to manually enable the serial console on NST versions 2.15.x or above using systemd. This example will use the current baud rate (agetty -s option) set typically during a boot time and use serial device: "/dev/ttyS0". If one needs to adjust the baud rate, send a break character on your communications application to cycle through the baud rate list (i.e., In this example: 115200, 38400 and 9600).

[root@probe ~]# systemctl start serial-getty@ttyS0.service
[root@probe ~]# 

A user login prompt should now be active on serial device: "/dev/ttyS0". To get the serial console status use the systemctl command as follows:

[root@probe ~]# systemctl status serial-getty@ttyS0.service
serial-getty@ttyS0.service - Serial Getty on ttyS0
          Loaded: loaded (/lib/systemd/system/serial-getty@.service)
          Active: active (running) since Tue, 17 May 2011 16:59:56 -0400; 5min ago
        Main PID: 31524 (agetty)
          CGroup: name=systemd:/system/serial-getty@.service/ttyS0
                  └ 31524 /sbin/agetty -s ttyS0 115200 38400 9600
[root@probe ~]# 

Add An Additional Serial Login Device: /dev/ttyUSB0

One can add an additional Serial user login session on a serial device. If your NST system does not have a physical serial port, you can plugin a USB To Serial Converter device for user login. In this example we are adding a USB To Serial Converter which attaches as device: "ttyUSB0". Simply start a serial login on this device as follows:

[root@probe ~]# systemctl start serial-getty@ttyUSB0.service
[root@probe ~]# 

A user login prompt should now be active on serial device: "/dev/ttyUSB0". To get the serial console status for this device use the systemctl command as follows:

[root@probe ~]# systemctl status serial-getty@ttyUSB0.service
serial-getty@ttyUSB0.service - Serial Getty on ttyUSB0
	  Loaded: loaded (/lib/systemd/system/serial-getty@.service)
	  Active: active (running) since Fri, 20 May 2011 21:13:55 -0400; 3min 24s ago
	Main PID: 1273 (agetty)
	  CGroup: name=systemd:/system/serial-getty@.service/ttyUSB0
		  └ 1273 /sbin/agetty -s ttyUSB0 115200 38400 9600
[root@probe ~]#

To make this configuration permanent add the following:

[root@probe ~]# ln -sf /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyUSB0.service
[root@probe ~]# systemctl daemon-reload
[root@probe ~]# systemctl start getty@ttyUSB0.service
[root@probe ~]#