- Linux Serial ConsoleВ¶
- HOWTO_Linux_serial_console
- Contents
- Check your system’s serial support
- Configure your inittab to support serial console logins
- Test serial port login with an external dumb terminal or terminal emulator
- Modifying the agetty settings
- Configure serial port as THE system console (Optional)
- Conclusion
- Linux Serial ConsoleВ¶
- Linux Serial ConsoleВ¶
Linux Serial ConsoleВ¶
To use a serial port as console you need to compile the support into your kernel — by default it is not compiled in. For PC style serial ports it’s the config option next to menu option:
Character devices ‣ Serial drivers ‣ 8250/16550 and compatible serial support ‣ Console on 8250/16550 and compatible serial port
You must compile serial support into the kernel and not as a module.
It is possible to specify multiple devices for console output. You can define a new kernel command line option to select which device(s) to use for console output.
The format of this option is:
You can specify multiple console= options on the kernel command line. Output will appear on all of them. The last device will be used when you open /dev/console . So, for example:
defines that opening /dev/console will get you the current foreground virtual console, and kernel messages will appear on both the VGA console and the 2nd serial port (ttyS1 or COM2) at 9600 baud.
Note that you can only define one console per device type (serial, video).
If no console device is specified, the first device found capable of acting as a system console will be used. At this time, the system first looks for a VGA card and then for a serial port. So if you don’t have a VGA card in your system the first serial port will automatically become the console.
You will need to create a new device to use /dev/console . The official /dev/console is now character device 5,1.
(You can also use a network device as a console. See Documentation/networking/netconsole.txt for information on that.)
Here’s an example that will use /dev/ttyS1 (COM2) as the console. Replace the sample values as needed.
Create /dev/console (real console) and /dev/tty0 (master virtual console):
LILO can also take input from a serial device. This is a very useful option. To tell LILO to use the serial port: In lilo.conf (global section):
Adjust to kernel flags for the new kernel, again in lilo.conf (kernel section):
Make sure a getty runs on the serial port so that you can login to it once the system is done booting. This is done by adding a line like this to /etc/inittab (exact syntax depends on your getty):
Init and /etc/ioctl.save
Sysvinit remembers its stty settings in a file in /etc , called /etc/ioctl.save . REMOVE THIS FILE before using the serial console for the first time, because otherwise init will probably set the baudrate to 38400 (baudrate of the virtual console).
/dev/console and X Programs that want to do something with the virtual console usually open /dev/console . If you have created the new /dev/console device, and your console is NOT the virtual console some programs will fail. Those are programs that want to access the VT interface, and use /dev/console instead of /dev/tty0 . Some of those programs are:
It should be fixed in modern versions of these programs though.
Note that if you boot without a console= option (or with console=/dev/tty0 ), /dev/console is the same as /dev/tty0 . In that case everything will still work.
Thanks to Geert Uytterhoeven @ linux-m68k . org> for porting the patches from 2.1.4x to 2.1.6x for taking care of the integration of these patches into m68k, ppc and alpha.
Источник
HOWTO_Linux_serial_console
Have you ever needed to connect a dumb terminal (like a Wyse 50) to a Linux host? Do you need to login to a Linux server from a laptop to perform administrative functions, because there is no monitor or keyboard attached to the server? If you are accustomed to administering routers, switches, or firewalls in this manner, then you may be interested in doing the same with some of your GNU/Linux hosts.
Contents
Check your system’s serial support
You may need to emerge sys-apps/setserial for this part.
First, let’s make sure that your operating system recognizes serial ports in your hardware. You should make a visual inspection and make sure that you have one or more serial ports on your motherboard or add-in PCI card. Most motherboards have two built-in ports, which are called COM1: and COM2: in the DOS/Windows world. You may need to enable them in BIOS before the OS can recognize them. After your system boots, you can check for serial ports with the following commands:
As you can see, the two built-in serial ports are /dev/ttyS0 and /dev/ttyS1.
Configure your inittab to support serial console logins
The /etc/inittab file must be reconfigured to allow serial console logins. You will note that the mingetty daemon is used to listen for virtual consoles (like the 6 that run by default with your keyboard and monitor). You will need to configure agetty or mgetty to listen on the serial ports, because they are capable of responding to input on physical serial ports. In the past, I have used both full-featured gettys. In this document, I will only discuss agetty, since it is already included in the default Red Hat 9 installation. It handles console/dumb terminal connections as well as dial-in modem connections.
What is a getty?
A getty is is a program that opens a tty port, prompts for a login name, and runs the /bin/login command. It is normally invoked by init.
Before you edit /etc/inittab, which is a very important config file, you should make a backup copy:
The required /etc/inittab additions are right below «# SERIAL CONSOLES»:
File: /etc/inittab |