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.
In the file/etc/inittab
Add the following line. [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 is running make config
, Select 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.