(原创)解决串口上无登录提示符,无法登录的问题

问题描述:

       制作好rootfs后,kernel能够引导rootfs进入到系统,但是串口上最终却没有登入提示符。使用SSH或者Telnet可以登入系统。无法使用串口进行登录系统,使用起来不方便。

问题分析:

       对照启动流程梳理,发现所设置的运行级别为3下的所有启动脚本均已执行(rc3.d),仅仅是最后没有提示登入符login:,从其他地方可以登入系统(ssh/telnet),说明系统的login程序已经执行,因此,可以大胆怀疑是在串口上的登入提示被重定向了,它应该是重定向和内核打印信息一样的位置,因此需要修改inittab文件,将登录进行重定向修正。

问题解决:

      下面是原版的inittab文件:


# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:5:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
PS0:12345:respawn:/bin/start_getty 115200 ttyPS0 vt102
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
#  <id>:<runlevels>:<action>:<process>
#

1:12345:respawn:/sbin/getty 38400 tty1


X0:12345:respawn:/sbin/getty-wrapper 115200 hvc0

上述文件说明,引导系统进入运行级别5,在串口上登入重定向到ttyPS0。

当前适配的系统需要运行级别设置为3,在串口上登入重定向到ttyAMA1,因此需要修改The default runlevel和PS0选项,修正后的inittab文件如下:

# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:3:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
PS0:12345:respawn:/bin/start_getty 115200 ttyAMA1 vt102
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
#  <id>:<runlevels>:<action>:<process>
#

1:12345:respawn:/sbin/getty 38400 tty1


X0:12345:respawn:/sbin/getty-wrapper 115200 hvc0

       将修改项合入到新的rootfs中,再次重启系统,串口上出现了久违而熟悉的login:登入提示符。

总结:

      initab文件是引导系统进行配置的重要文件,它设定系统的运行级别、登入前的自启动运行程序,以及登入时的重定向,文件很简短。

posted on 2023-08-29 08:34  Booting  阅读(451)  评论(0编辑  收藏  举报