How to direct the LINUX console to a serial port terminal

Source: Internet
Author: User
Article Title: how to direct the LINUX console to a serial port terminal. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open 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
Example:
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
# Define CONFIG_SERIAL_ECHO
Next, modify the serial port address (only when the port you use is different from the default definition ).
# Define SERIAL_ECHO_PORT 0x3f8/* COM1 */
Or:
# 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 = SERIAL_LINE, SPEED PARITY BITS
  
Here:
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 = 1, 9600n8
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.

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: info-contact@alibabacloud.com 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.