LinuxRedirectionConsole PortThe procedure of the console is as follows:
First, the redirection rules are slightly different because of different Linux versions. Therefore, here we only describe the Linux ora13 Linux system.
All the output from Linux Startup to startup is copied to the comport. A total of three files need to be modified. Before that, check whether the/sbin/agetty file exists. This file is used to map system input and output to other devices.
1. Add the following content to the/etc/inittab, and add one line to the last line:
sc:2345:respawn:/sbin/agetty ttyS0 1152000,115200 xterm
"SC" indicates the ID of the command to be modified. "2345" indicates that the running level of the command to be modified is 2, 3, 4, or 5. "respawn" indicates that the command is executed again after exiting, so that other users can log on. "/sbin/agetty ttyS0 9600 vt100" indicates the specific command, that is, you can use it to open the serial port/dev/ttyS0 (COM1 ), followed by the baud rate and Terminal Mode
Xterm is a standard virtual terminal on X Window System. You can enable many xterms on the same monitor, and each of them provides independent input and output for processes running in it. Generally, this process is a Unix shell ).
2. modify the content in/etc/securetty:
Add one row to the second row: ttyS0
This file is a list of tty devices that allow root login. These devices are read by the/bin/login program, you need to add "ttyS0" to the file, which means the system considers COM1 safe;
3. modify the content in the/etc/grub. conf file:
Redirect grub:
Adding another line in the # Enable Serial Console may have errors.) Add:
serial --unit=0 --speed=115200 --word=8 --paity=no --stop=1 terminal --timeout=10 serial console serial
Initialize a serial device.
Redirection console:
In the/etc/grub. conf file, add the following lines to the kernel statement:
console=tty0 console=ttyS0,115200n8
"TtyS0", "0" indicates that the serial port uses COM1; "9600" indicates that the baud rate is 9600bps; "n" indicates that there is no parity bit; "8" indicates that there are eight data bit.
In fact, the information during Linux Startup is displayed by KERNEL. By default, after the startup is complete, init runs mingetty to provide 6 virtual terminals to log on to the system, this can be clearly seen in the/etc/inittab file. In fact, login has no relationship with the kernel. Therefore, if you only add parameters to the kernel so that it can perform interactive operations from the comport, it does not mean that you can log on to the system from the Super Terminal, we need to run another program that provides the login capability from the serial port. This program is agetty, which is a member of the util-Linux software package, you can refer to the man manual page for more information, which is also mentioned in other documents [1] [3.
There are limits on the transmission distance of the comport, and the normal cable is only 15 meters of valid distance. We recommend that you use five twisted pair wires, which can be expanded to 50 meters and still operate normally;
Generally, if you want to use root to log on from ttyS0, this cannot be done by default. We need to add this terminal to the file/etc/securetty, that is, the terminal ttyS0 is a secure terminal, you can use root to log on. If the server is on for a long time, you 'd better use exit to exit the terminal every time, because if you do not exit, the terminal may be unavailable due to garbled characters during next login, but inputting garbled characters at the logon prompt is irrelevant;
If you manage a 24x7 server in this way, you may find that pressing the carriage return on the terminal does not reflect any problems, there is a possibility that services such as NFS and sendmail cannot be started after the system is powered off and then started up, so it gets stuck there, which is especially common in the case of unstable power supply, so be sure to connect your Linux server to the UPS for uninterrupted power supply, or set the power-off in the system BIOS to stop starting the system (if it is not too important ), in this case, you only need to press the keyboard to restart or power down and restart again. Check what happened during the startup process. Generally, you only need to check the hard disk once;
If your ttyS0 is garbled and cannot be used, you can try to log on from the network and comment out the line ttyS0 in the/etc/inittab, run the "init q" command to stop the agetty started through inittab, then cancel the comments in/etc/inittab again, and run the "init q" command to start agetty again, it can be recovered without an accident.