Serial console linux ��� ���

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:

Читайте также:  Самая легкая сборка windows 10 2020

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»:

agetty options explained:

  • -L force line to be local line with no need for carrier detect (when you have no modem).
  • -f alternative /etc/issue file. This is what a user sees at the login prompt.
  • -i do not display any messages at the login prompt.
  • 9600 serial line rate in bps. Set this to your dumb terminal or terminal emulator line rate.
  • ttyS0 this is the serial port identifier.
  • vt100 is the terminal emulation. You can use others, but VT100 is the most common or «standard». Another widely used termial type is VT102.

Possible serial line rates (sometimes called baud rates) for the 16550A UART:

  • 110 bps
  • 300 bps
  • 1200 bps
  • 2400 bps
  • 4800 bps
  • 9600 bps
  • 19,200 bps
  • 38,400 bps
  • 57,600 bps
  • 115,200 bps

I have tried all of these line rates. 9600 bps is generally O.K., and is a very common setting for networking hardware. 38,400 bps is the speed of the standard Linux console, so it is my second choice. If your dumb terminal or terminal emulator cannot handle 38,400 bps, then try 19,200 bps: it is reasonably speedy and you will not be annoyed.

Here was my custom issue file, /etc/issueserial. It uses escape sequences defined in the agetty manpage to add some useful information, such as the serial port number, line speed, and how many users are currently logged on:

Now, you must activate the changes that you made in /etc/inittab. This is done with the following command, which forces the init process to re-read the configuration file:

Now, let’s make sure that the agetty process is listening on the serial ports:

Test serial port login with an external dumb terminal or terminal emulator

I have tested this setup with a WYSE dumb terminal, a Linux laptop running Minicom, and Windows 2000/XP laptops running HyperTerminal. They all worked just fine.

Terminal settings: should be 9600, N, 8, 1. Terminal emulation should be set to VT100 or VT102. Turn flow control off. If you want to use the 38,400 bps serial port on ttyS1, then your settings should be adjusted to 38400, N, 8, 1.

Cable: To connect a laptop to the serial port on the Linux host, you need to have a null-modem cable. The purpose of a null-modem cable is to permit two RS-232 DTE devices to communicate with each other without modems between them. While you can construct this yourself, a good, sturdy manufactured null-modem cable is inexpensive and will last longer.

If you insist on making the cable yourself, then check out Nullmodem.Com for the wiring and pinout diagram.

Connectors: Motherboard serial ports are typically male DE-9 connectors, but some serial ports use DB-25 connectors. You may need some DE-9 to DB-25 converters or gender-changers in order to connect to your terminal. For a typical laptop to server connection, a DE-9 null-modem cable should be sufficient.

Here is what you should see on the dumb terminal or terminal emulator:

Note: If you want to be able to login via serial console as the root user, you will need to edit the /etc/securetty config file. The entries to add are highlighted in red:

Modifying the agetty settings

If you want to change the baud rate or some other agetty setting, you will need to perform these 3 steps:

  1. Modify the /etc/inittab configuration file
  2. Activate the config change by forcing init to re-read the config file
  3. Restart the agetty daemons

Here is an example of steps 2 and 3:

Configure serial port as THE system console (Optional)

You can use options in /etc/grub.conf to redirect console output to one of your serial ports. This can be handy if you do not have a keyboard or monitor available for the Linux host in question. You can also see all of the bootup and shutdown messages from your terminal. In this example, we will make the /dev/ttyS1 port be the console. The text to add to the config file is highlighted in red:

Now, if you drop your system into single user mode with the «init 1» command, you will still be able to administer the system from your serial-connected terminal. No monitor or keyboard is required!

Warning!: The kudzu hardware detection program may «choke» on boot when the serial port becomes the console, instead of the video adapter. To remedy this situation, you should disable kudzu (assuming that your hardware is configured properly and won’t be changing). This is how you would do that:

You should also know how to break into the Grub bootloader during system startup and edit the kernel line. By deleting the console argument from the kernel line, you can boot the system with the standard console, which uses the video card and attached keyboard. You have been warned!

Conclusion

Now, you should be able to login from the serial ports on your GNU/Linux host. This could be useful for maintenance or for serving a whole room full of dumb terminals. In the future, I will investigate a PCI multiport serial card in the latter role.

Источник

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.

Источник

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.

Источник

Читайте также:  Windows server monitoring system
Оцените статью
File: /etc/inittab