linux console的利用

公司linux设备出现问题的时候,网络不同,没有办法操作。有的代理商,配置的ip都记不住,设备没有恢复出厂设备按钮。

以前只能接显示器,有的还要打开机箱盖,NND的麻烦啊。

 

所以啊,想了一个办法,像配置交换机一样。使用console口,连接。配置。

开始网络寻找,找到了方法,给童鞋们分享一下。

 

1.grup的配置/boot/grub/grub.conf

# 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 /, eg.
#          root (hd1,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sdb1
#          initrd /boot/initrd-version.img
#boot=/dev/sda
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1 
terminal --timeout=10 serial console
default=0
timeout=5
#splashimage=(hd0,0)/boot/grub/splash.xpm.gz     ####图像建议去掉
hiddenmenu
title Fedora Core (2.6.11-1.1369_FC4)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/1 console=tty0 console=ttyS0,9600n8
        initrd /boot/initrd-2.6.11-1.1369_FC4.img

 

console在linux下是字符设备。ttys0.ttys1,ttys2...... 

tty0 是linux没有启动起来的时候,内核对应的接口(我自己理解是这样)

ttys0,则是linux console 的表示。

 

2.修改/etc/inittab

[root@localhost etc]# cat /etc/inittab
#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, <>
#               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

# 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 powerd installed and your
# UPS 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 ttyS0 9600 vt100-nav
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
s0:2345:respawn:/sbin/agetty -L -f /etc/issue.serial 9600 ttyS1 vt100


# Run xdm in runlevel 5
x:5:once:/etc/X11/prefdm -nodaemon
3. 修改/etc/securetty

tty安全设置,系统允许ttys0登录。添加ttyS0

[root@localhost etc]# cat /etc/securetty
console
vc/1
vc/2
vc/3
vc/4
vc/5
vc/6
vc/7
vc/8
vc/9
vc/10
vc/11
tty1
tty2
tty3
tty4
tty5
tty6
tty7
tty8
tty9
tty10
tty11
ttyS0

然后用重启用putty或者SecureCRT。不建议用系统的超级终端,因为编辑文件的时候,无法编辑。

至少我没有找到方法。

我用的是putty

ok 不懂的 童鞋可以留言。 加QQ交流。欢迎拍砖。。。