Embedded 版 (精华区)
发信人: snows (花自飘零水自流), 信区: Embedded
标 题: The /sbin/init Program
发信站: 哈工大紫丁香 (2004年03月16日13:31:16 星期二), 站内信件
The /sbin/init Program
The program /sbin/init (hereafter called just init) is the parent of all user
processes. Init's job is to create other user processes by following the
instructions found in the file /etc/inittab. Technically, the kernel itself
has completely booted before init runs--- it has to, since init is a user
process. Despite this, most consider init to be "part of the boot process".
The inittab script usually has entries to tell init to run programs like
mingetty that provide login prompts, and to run scripts like those found in
/etc/rc.d/rc3.d that in turn start still more processes and services like
xinetd, NFS, and crond. As a result, a typical Linux workstation environment
may have as many as 50 different processes running before the user even logs
in for the first time.
Workstations usually modify system behavior by modifying the contents of
inittab, or the contents of the subdirectories under /etc/rc.d. This
capability makes it easy to make large-scale changes to a system's runtime
behavior without needing to recompile (or in some cases, even reboot) the
system. The conventions followed by inittab and /etc/rc.d scripts are well
documented and pervasive (they predate Linux by a number of years), and lend
themselves to automated modification during installation of user software.
To change the final stages of an embedded Linux startup process, you can
either provide a modified inittab and run init, or you can replace init
entirely, with an application of your own design--- perhaps your embedded
application itself. You can even experiment a bit, by providing the names of
programs like /bin/sh in the kernel's init= command line parameter of a Linux
workstation. The kernel will simply run the specified program at the end of
the boot process, instead of init.
Figure 11 shows an excerpt from a typical inittab file, that runs the scripts
in /etc/rc.d/rc.sysinit and /etc/rc.d/rc3.d, and launches a few mingetty's to
provide login prompts.
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
# 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
Figure 11. Excerpt from a typical inittab.
--
-
╭────────────────────────────╮
│ 风萧传瑟声,叶落根深处,青阶入野无归途,他乡不知顾 │
│ 泣下问和谁,叹者行已暮,寒眉傲骨今尚在,奈何入凡土 │
╰────────────────────────────╯
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.229.154]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.254毫秒