Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

solaris /etc/inittab file

Status
Not open for further replies.

s2budd

Technical User
May 15, 2001
30
GB
Can someone clear something up for me that has been bugging me about the /etc/inittab file.
I have looked in my reference books but still do not get it.

1. When moving to init 2. Are the /sbin/rc0 scripts run
and then the /sbin/rc1 scripts and then the /sbin/rc2
scripts or is it just the /sbin/rc2 that are executed.

2. The line starting with: "s2:23:wait:/sbin/rc2" -
Does the "23" mean that the scripts are executed at
both run levels 2 & 3.

Thanks in advance

Stuart
 
Well, I'm not completely sure, but here's how I THINK it works.

First of all, the program [tt]init[/tt] is the process responsible for booting unix, and taking it to different run levels. The file [tt]/etc/inittab[/tt] is the file that, at a high level, tells [tt]init[/tt] what to do when going to and from different run levels. The detail of what takes place to get to or from each run level is in the [tt]/sbin/rc*[/tt] scripts and the scripts in [tt]/etc/rc*.d[/tt].

For discussion, here's my inittab (slightly edited)...
[tt]
ap::sysinit:/sbin/autopush -f /etc/iu.ap
ap::sysinit:/sbin/soconfig -f /etc/sock2path
fs::sysinit:/sbin/rcS sysinit
is:3:initdefault:
p3:s1234:powerfail:/usr/sbin/shutdown -y -i5 -g0
sS:s:wait:/sbin/rcS
s0:0:wait:/sbin/rc0
s1:1:respawn:/sbin/rc1
s2:23:wait:/sbin/rc2
s3:3:wait:/sbin/rc3

s5:5:wait:/sbin/rc5
s6:6:wait:/sbin/rc6
fw:0:wait:/sbin/uadmin 2 0
of:5:wait:/sbin/uadmin 2 6
rb:6:wait:/sbin/uadmin 2 1
sc:234:respawn:/usr/lib/saf/sac -t 300
co:234:respawn:/usr/lib/saf/ttymon -g -h -p "`uname -n` console login: " -T sun
-d /dev/console -l console -m ldterm,ttcompat
[/tt]
The second parameter, delimited with colons, is the [tt]rstate[/tt], or run state. This defines the run level in which this entry is to be processed. So yes, when there is a "23" there, this means that this script, the [tt]/sbin/rc2[/tt] will be run when going to run level 3. Each line that has the number of the run state we're moving to will be run to get to that run level, if it has a "wait" in the next field.

When the system is booting, the lines with "[tt]sysinit[/tt]" are run first. This is what's done when coming up from a run level 0 or a fresh power up. You's notice that this gets the "Single user mode" script [tt]/sbin/rcS[/tt] to run.

Then [tt]init[/tt] looks for the line with "[tt]initdefault[/tt]" in the third field. This tells it which is the poweron default run level. In this case 3.

To get to run level 3, I believe it will run each init script ([tt]/sbin/rc*[/tt]) that has a 3 in the second field. So from a power-on that should be, in order...
[tt]
ap::sysinit:/sbin/autopush -f /etc/iu.ap
ap::sysinit:/sbin/soconfig -f /etc/sock2path
fs::sysinit:/sbin/rcS sysinit
s2:23:wait:/sbin/rc2
s3:3:wait:/sbin/rc3
sc:234:respawn:/usr/lib/saf/sac -t 300
co:234:respawn:/usr/lib/saf/ttymon -g -h -p "`uname -n` console login: " -T sun
-d /dev/console -l console -m ldterm,ttcompat
[/tt]
So you see, rcS, rc2, and rc3 get run in that order when the system is booted.

The "[tt]wait[/tt]" makes it wait until that level is done before going to the next. The "[tt]respawn[/tt]" lines are run whenever [tt]init[/tt] processes the inittab file.

You can actually look at the [tt]/sbin/rc*[/tt] scripts. They have some logic where they look to see if they're moving up to that run level, or down to it, and process the scripts accordingly.

The man pages for "[tt]init[/tt]" and "[tt]inittab[/tt]" have more info, but I believe this is how it works at a high level.

Hope this helps.

(putting on flame retardant T-shirt)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top