Solaris bootup sequence...

Solaris bootup sequence...

Post by bo.. » Tue, 14 Sep 1999 04:00:00



Just for my own intellectual gratification, I added the
following script as K99showrunlevel and S99showrunlevel
to /etc/rc3.d.

#!/bin/sh

runlvl=`who -r | awk '{print $3}'`

echo
echo $1 FOR RUNLEVEL $runlvl COMPLETE!
echo

# End script

Now, what is odd is that when I boot up from the OK prompt into
runlevel 3 it gives me

start FOR RUNLEVEL 3 COMPLETE!
stop FOR RUNLEVEL 3 COMPLETE!
start FOR RUNLEVEL 3 COMPLETE!

Which surprised me, looking at the rc3 script it should only run
start once, and should not run it before stop, it should go
after stop.  (Oh Solaris 2.6 and 2.7).

So can anyone explain to me what is going on?

Thanks in advance.

Roger Books
-------------------------------------------------------
| Unix sysadmin, Unix group         |                 |
| Information Technology Program    |                 |
| Dept of Mgmt Services             |                 |
| State of Florida                  |                 |
-------------------------------------------------------

 
 
 

Solaris bootup sequence...

Post by Mark Mentova » Tue, 14 Sep 1999 04:00:00


Roger Books wrote in comp.unix.solaris:

Quote:>Just for my own intellectual gratification, I added the
>following script as K99showrunlevel and S99showrunlevel
>to /etc/rc3.d.

>#!/bin/sh

>runlvl=`who -r | awk '{print $3}'`

>echo
>echo $1 FOR RUNLEVEL $runlvl COMPLETE!
>echo

># End script

>Now, what is odd is that when I boot up from the OK prompt into
>runlevel 3 it gives me

>start FOR RUNLEVEL 3 COMPLETE!
>stop FOR RUNLEVEL 3 COMPLETE!
>start FOR RUNLEVEL 3 COMPLETE!

>Which surprised me, looking at the rc3 script it should only run
>start once, and should not run it before stop, it should go
>after stop.  (Oh Solaris 2.6 and 2.7).

>So can anyone explain to me what is going on?

Yes.  But you need to know the facts and not the myths about how init
and the rc? scripts work.

Take a look at your /etc/inittab.  It's probably got these lines (more
or less):

is:3:initdefault:
s2:23:wait:/sbin/rc2 >/dev/msglog 2<>/dev/msglog </dev/console
s3:3:wait:/sbin/rc3  >/dev/msglog 2<>/dev/msglog </dev/console

What does this all mean?  The first line of my mini-listing gives the
default run-level as 3.  The second and third lines tell init what to
do as far as the rc? scripts go for run-level 3.  You might be
surprised to find that this means the rc2 script is invoked in
run-level 3 before the rc3 script, rather than invoking rc2 in
run-level 2 and then switching to run-level 3.  With that in mind, I
bet you have S99showrunlevel in rc2.d as well as rc3.d, but were
expecting it to notify you that the start for run-level 2 had
completed.

As for the stop of run-level 3, that is because of how the rc? scripts
themselves work.  Take a look at the part of rc3 (or any other rc?
script for that matter) that runs the K and S scripts, and you will see
(this has been grossly oversimplified as an example):

for f in /etc/rc3.d/K*; do
  /sbin/sh $f stop
done
for f in /etc/rc3.d/S*; do
  /sbin/sh $f start
done

While many people expect the K* files in a given rc?.d directory to be
run when that run-level is exiting (example, run rc2.d/K* when exiting
run-level 2), this is in fact not the case.  The K* files are run when
entering a run-level, prior to the S* files.  Rather than cleaning up
after the user is finished with a run-level, the K* files are intended
to clean up before the user enters one.  Anything that is not supposed
to run in a given run-level should have a K* file to get rid of it.

In your case, rc3.d/K99showrunlevel (with the argument "stop") runs
just before rc3.d/S99showrunlevel (with the argument "start").  Both of
these are running just after the rc2.d/S99showrunlevel (argument
"start") that I suspect you have.  (And if there's an
rc2.d/K99showrunlevel, then it too gets run along with the other
rc2.d/K* files, but while the system is doing all of the rc2.d/S*
stuff, there's plenty of screen output, so it would not appear with the
other messages.)  All of this occurs while, as far as the system is
concerned, the run-level is 3.

-MM

 
 
 

Solaris bootup sequence...

Post by Rainer Hur » Wed, 15 Sep 1999 04:00:00


: Yes.  But you need to know the facts and not the myths about how init
: and the rc? scripts work.
:
[...]

Excellent posting. Thank you.

Rainer

--
Rainer Hurle
Software Engineer
GE marquette hellige

 
 
 

Solaris bootup sequence...

Post by bo.. » Thu, 16 Sep 1999 04:00:00


Thanks for the info, excellent explanation.

Roger Books
-------------------------------------------------------
| Unix sysadmin, Unix group         | (850)921-0729   |
| Information Technology Program    |                 |
| Dept of Mgmt Services             |                 |
| State of Florida                  |                 |
-------------------------------------------------------

 
 
 

Solaris bootup sequence...

Post by bo.. » Thu, 16 Sep 1999 04:00:00


Odd, when you boot to runlevel 3 the rc2 script only does the S
scripts, not the K scripts.  Also, if I want to add a runlevel
4 it looks like I will have to modify rc2 and rc3 as well as
the inittab.

The other thing that surprised me was you don't go through
runlevel 1 to get to runlevels 2 and 3.

One character in the inittab and you have the default linux
behavior.  What I should probably do is modify my home linux
box to match all the Solaris boxes at work.  A misunderstanding
about linux causes me minor inconvenience, a misunderstanding
about Solaris causes everyone problems.

Roger Books
-------------------------------------------------------
| Unix sysadmin, Unix group         |                 |
| Information Technology Program    |                 |
| Dept of Mgmt Services             |                 |
| State of Florida                  |                 |
-------------------------------------------------------