telinit 和 rc*.d 下手动运行脚本的区别

telinit 和 rc*.d 下手动运行脚本的区别

我正在尝试调试我的 Linux 启动过程。如果我将默认运行级别设置为 2 或 3,我的系统将挂起而不给出提示。我能够通过内核参数进入运行级别 1,并/etc/rc2.d通过service ***** start/stop命令运行所有脚本,一切都很好。但如果我执行telinit运行级别 2 或 3,我就看不到 shell 提示符。那么这两种方法有什么区别呢?

我使用 SysVinit。内容/etc/inittab(我没有修改过):

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"


# agetty on serial port
s0:2345:respawn:/sbin/agetty -L -i 9600 ttyS0 vt100
s1:2345:respawn:/sbin/agetty -L -i 9600 ttyS1 vt100

1:2345:respawn:/sbin/agetty 38400 tty1 linux

# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon

# Ask for password at single user prompt
~~:S:wait:/sbin/sulogin

答案1

init所做的不仅仅是运行/etc/rc.d.

其一,它在每个虚拟终端上生成mingetty或。getty检查您是否没有注释掉以下行,或者附近有拼写错误:

# Run gettys in standard runlevels
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

(请注意,我目前没有使用 RHEL/CentOS 系统,因此没有保证!)

相关内容