Directs the LINUX console to a serial port terminal

Source: Internet
Author: User
Tags echo command
Author: gauss (resend) Source: uses a serial port terminal as the Linux console, eliminating the need for additional keyboards, display cards, and monitors, while Linux hosts can be used as an embedded black box for any purpose. It is not difficult to connect the serial port terminal to the computer's serial port. refer to the Linux HOWTO

Author: gauss (posting) Source:

Using a serial port terminal as the Linux console, you can remove the need for additional keyboards, display cards, and monitors, and use the Linux host as an embedded black box for any purpose. It is not difficult to connect a serial port terminal to a computer's serial port. you can refer to the Linux HOWTO document and help information of inittab and agetty. Here is a brief introduction.
First, prepare a null modem cable.
Next, add the following line to the/etc/inittab file. [Note: If you do not use the agetty program, use other programs such as like getty_ps to apply the correct command syntax]
ID: RUNLEVELS: respawn:/sbin/agetty-L SPEED TTY TERM
Here: ID = a two-letter identifier, such as s1 or s2.
RUNLEVELS = terminal activation running level
SPEED = serial port SPEED
TTY = serial device name
TERM = TERM environment variable
S2: 12345: respawn:/sbin/agetty-L 9600 ttyS1 vt100
Indicates that the serial port/dev/ttyS1 (COM2) speed is 9600 bps, and the terminal mode is vt100.
Finally, restart the machine.
If you follow the preceding three steps correctly, you can see a Login: prompt on the terminal screen. You can log on to the system and work as if you were logging on to the console or remotely using Telnet.
The following describes how to set the terminal to the console, which mainly involves kernel information, startup script information, and LILO information.

I. kernel information
The information displayed when the system starts is always output to the main console (tty1 ). After the machine is turned on, you only have to wait for Login: to appear on the terminal screen, which means that all the startup information is unknown. You only need to run the dmesg command after logging on, but usually want to see this information before login shell is started.
Other information is displayed on the console, such as the output information such as the script commands that run when the script command is executed in the/etc/rc. d Directory, and the script commands run when the machine is started and terminated. If the information does not appear on the screen, how can we truly know that "the system has been terminated?
You must modify the source code/usr/src/linux/drivers/char/console. c [the kernel source code must have been installed]. this is not a complicated kernel modification. perform the following three steps:
First, define CONFIG_SERIAL_ECHO in front of the program
Next, modify the serial port address (only when the port you use is different from the default definition ).
# Define SERIAL_ECHO_PORT 0x3f8/* COM1 */
# Define SERIAL_ECHO_PORT 0x2f8/* COM2 */
Third, recompile the kernel [refer to the relevant Manual] to start the machine. When the system detects hardware devices, you should see the information on the terminal screen.
Note: Except for the Alpha platform, the console. c patch is required for all Linux ports. On the Alpha platform, it runs make config and selects the following options:
Echo console messages on/dev/ttyS1

II./etc/rc. d/rc. * startup script information
To display this information on the terminal, you can append the lines containing the echo command in these files to "> TTY ". TTY is the serial port of the terminal (the same as the serial port line in/etc/inittab ).

3. LILO configuration
To start one of the two kernels, you must modify the LILO configuration file/etc/lilo. conf. Configure LILO to display the prompt information on the terminal. for details, refer to the/usr/doc/lilo/README file (view the SERIAL option ). The following two steps are provided:
First, edit/etc/lilo. conf file and insert a SERIAL option after the BOOT option line.
SERIAL_LINE = 0 (serial port 1)
1 (serial port 2)
2 (serial port 3)
3 (serial port 4)
SPEED = serial SPEED
PARITY = n (= None)
O (= odd check)
E (= even verification)
BITS = data bit (8 or 7)
Note: There is no space between the speed parity and BITS parameters. These parameters must be the same as those set at terminal. The following is an example of LILO configuration:
Serial = 19600n8
This line indicates COM2, with a rate of BPS, no parity bit, and 8 data bit.
Second, run the lilo command to refresh the system configuration.
With the SERIAL option, LILO sets a latency of 2 seconds before starting the default kernel. During this period, you can press the "SHIFT" key on the terminal to send a termination signal, terminate the boot process, and obtain the LILO prompt.
After completing the preceding configuration, your terminal can be used as a console. One thing that cannot be done is to restart the system with a CTRL-ALT-DEL.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.