Showing posts with label console. Show all posts
Showing posts with label console. Show all posts

2013-10-04

Enable serial console

When running servers, it can be very useful to enable a serial console. Accomplishing this entails:
  1. Telling the kernel that we want a serial console
  2. Telling init that we want a login prompt on the serial device

Kernel command line


It is possible to specify a serial console using the console parameter on the kernel command line. The kernel receives its command line parameters from the bootloader (GRUB or GRUB2). Here's how to set that up:

System-wide default


Regardless of whether I'm running and older SLE11 machine with GRUB or a newer openSUSE or SLE12 machine with GRUB2, first I edit /etc/sysconfig/bootloader to modify the DEFAULT_APPEND setting by adding onsole=tty0 console=ttyS0,115200n8 to whatever is already there:
change, e.g., DEFAULT_APPEND="   splash=silent quiet showopts" to

DEFAULT_APPEND="   splash=silent quiet showopts console=tty0 console=ttyS0,115200n8"

Now, this value will only ever be used for future kernels. To enable the serial console right from the next boot, I will need to edit the existing kernel command lines in the GRUB configuration file. How to do that depends on whether my system is using GRUB or GRUB2.

GRUB


For GRUB v.1 machines, the file is /boot/grub/menu.lst. Add the following to the end of each kernel command line:
console=tty0 console=ttyS0,115200n8

GRUB2


For GRUB v.2 machines, edit the file /etc/default/grub and add that text to the end of the GRUB_CMDLINE_LINUX_DEFAULT option and then do:
# grub2-mkconfig -o /boot/grub2/grub.cfg

Login prompt


And to get login prompt on the serial console, enable ttyS0 in inittab like this:
tim:~ # grep ttyS0 /etc/inittab
S0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt102

And of course add ttyS0 to /etc/securetty and run 'init q'

2012-12-31

Text console: i18n, locales and UTF-8

Gone are the days of fiddling with configurations and fonts in order to get one's text terminal (or xterm) to display international character sets properly -- and good riddance! Still, even today it is still possible to misconfigure one's terminal. And what to do if you need to find the hex value of an international character, or vice versa?

2012-01-30

Thorbjørn Ravn Andersen's 1997 whitepaper "Colours with Linux terminals"

These days, when someone refers to the Linux console, they usually mean some kind of xterm in some kind of desktop environment. But for us old fogies, the text console, or virtual console, has not lost its allure or usefulness. Yesterday I needed to change the background color in the framebuffer text console, and this ancient whitepaper was where I found how to do it (and make it stick):

6. How to change the text-mode default from white-on-black

You will need to tell the terminal driver code that you want another default. There exists no standard way of doing this, but in case of Linux you have the setterm program.

setterm uses the information in the terminal database to set the attributes. Selections are done like
setterm -foreground black -background white -store
where the -store besides the actual change makes it the default for the current console as well. This requires that the current terminal (TERM environment variable) is described "well enough" in the termcap database. If setterm for some reason does not work, here are some alternatives:

Without the -store parameter, the color change remains in effect only until the next time a program (like ls or man) changes it back to white-on-black. For the rest of the whitepaper, see:

Colours with Linux terminals




Chip Coldwell's 2003 whitepaper "Terminal Concepts in GNU/Linux"

In 2003, my friend Chip Coldwell (also known as "the Terminal Whisperer") wrote a good introduction to character cell terminals in Linux:
Terminal Concepts in GNU/Linux
Highly recommended.

George Hansper's 1998 article "Virtual Consoles in Linux"

Virtual Consoles in Linux

Stale links are one of my Internet pet peeves. Often there's a great article "out there", but the links to it have gone stale.

Therefore, instead of posting just a link to George Hansper's great article "Vitual Consoles in Linux", I decided to post the link AND reproduce the entire article.

Linux console (text mode, framebuffer): change background color

The magic incantation you're looking for is:
$ setterm -background blue -store

For more information, see:
$ man setterm