歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 在引導期間配置 Linux 進行串行重定向

在引導期間配置 Linux 進行串行重定向

日期:2017/2/28 16:29:41   编辑:Linux教程

“SysRq key” 是允許將基本命令直接傳遞給內核進行調試的鍵序列。 在有些情況下,還可以用來重新引導遠程管理系統。 串行控制台使用 RS-232 中斷函數,比如 SysRq 鍵。 “中斷”是在串行線上不進行傳輸的一段時間。 要在運行 Linux 的系統中配置 “Sysrq” 鍵,應遵守以下指令:

注:以下指令特定於 Linux GRand Unified Bootloader (GRUB)。 使用其他啟動裝載程序時,也有必要進行類似更改。
注:在配置客戶端 VT100 仿真窗口時,必須將顯示重定向控制台的窗口或應用程序設置為 25 行 x 80 列以確保正確的文本顯示;否則,有些文本屏幕會顯示混亂。

如下編輯文件 /etc/grub.conf。 請參閱後面的示例文件,其中顯示了本步驟中所述的更改。

將以下兩行新內容添加到文件的常規設置部分:
serial --unit=0 --speed=19200
terminal --timeout=10 serial

將兩個選項附加到內核行:
kernel ............. console=ttyS0,19200

如果 /etc/grub.conf 包含 splashimage 指令,必須將其注釋掉。
這個使用波特率 19200 的示例文件是一個例子。以下是 BMC 串行通信和 SOL 允許的最大波特率:

對於 PowerEdge 1425SC 和 其他 PowerEdge x8xx 系統為 19200。
對於不帶 Dell Remote Access Controller (DRAC 5) 的 PowerEdge x9xx 系統為 57600。
對於帶 DRAC 5 的 PowerEdge x9xx 系統為 115200。

表 D-1. 示例文件:/etc/grub.con

# grub.conf generated by anaconda
#
Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, e.g.

# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/sdal
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=10
#splashimage=(hd0,2)/grub/splash.xpm.gz

serial --unit=0 --speed=19200
terminal --timeout=10 serial

title Red Hat Linux Advanced Server (2.4.9-e.3smp)
root (hd0,0)
kernel /boot/vmlinuz-2.4.9-e.3smp ro root=/dev/sda1 hda=ide-scsi console=tty0 console=ttyS0,19200
initrd /boot/initrd-2.4.9-e.3smp.img
title Red Hat Linux Advanced Server-up (2.4.9-e.3
root (hd0,00)
kernel /boot/vmlinuz-2.4.9-e.3 ro root=/dev/sda1 s
initrd /boot/initrd-2.4.9-e.3.im

有關編輯 grub.conf 的其它信息:

可能需要禁用 GRUB 的圖形界面並轉而使用www.linuxidc.com基於文本的界面;否則,GRUB 屏幕將不會在 BMU 控制台重定向中顯示。 要做到這一點,注釋掉以 splashimage 開頭的行。

如果在 GRUB 中有多個選項並且希望所有選項都通過 BMU 串行連接啟動控制台會話,則為所有選項添加 console=ttyS1,19200。 以上示例只顯示將 console=ttyS0,19200 添加到第一個選項。
在引導後啟用登錄到控制台
如下編輯文件 /etc/inittab:

添加新行在 COM1 串行端口上配置 getty:

co:2345:respawn:/sbin/agetty -h -L 19200 ttyS0 vt100

請參閱示例文件,其中顯示添加了新行。

表 D-2. 示例文件:/etc/innitab

#

# inittab This file describes how the INIT process should set up
# the system in a certain run-level.

#
# Author: Miquel van Smoorenburg, <[email protected]
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have
# networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

# Things to run in every runlevel.
ud::once:/sbin/update

# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has failed, assume we have a few
# minutes of power left. Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have power installed and your
# UPS is connected and working correctly.
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"

# Run gettys in standard runlevels
co:2345:respawn:/sbin/agetty -h -L 19200 ttyS0 vt100
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5
# xdm is now a separate service
x:5:respawn:/etc/X11/prefdm -nodaemon


如下編輯文件 /etc/securetty:

添加新行,為 COM1 使用串行 tty 名稱:

ttyS0

Copyright © Linux教程網 All Rights Reserved