Hello folks,
I have been working with UNIXes/Solaris/Linux for a couple of years and
I finally decided to read a little bit about runlevels, boot and
shutdown process.
I know how to work with it in practice, creating the init.d and rc.d
scripts and sym links, yada, yada, yada, but let me see if you can help
me to match my practice knowledge with the theory.
01. How are the runlevels transitions during a boot process? Does it
goes from runlevel 0 then 1, then 2 and then 3 or does it got straight
to runlevel 3?
02. How is the runlevel transition during a clean shutdown process?
Does it goes backwards passing through each intermediate runelevel,
i.e. from 3 to 2, then 1, then 0 or does go straight to runlevel 0 (or
5)?
03. Generally speaking, if I am at runlevel X how does it transition to
runlevel Y? For example, if I am at 3 how does goes to 1? Does it goes
first to 2?
Thanks in advance and regards,
PS: Sorry if I am not using the right terms.
|
|
0
|
|
|
|
Reply
|
hugoksouza (1)
|
7/31/2006 4:29:47 PM |
|
Kamikaze wrote:
> Hello folks,
>
> I have been working with UNIXes/Solaris/Linux for a couple of years and
> I finally decided to read a little bit about runlevels, boot and
> shutdown process.
>
> I know how to work with it in practice, creating the init.d and rc.d
> scripts and sym links, yada, yada, yada, but let me see if you can help
> me to match my practice knowledge with the theory.
>
> 01. How are the runlevels transitions during a boot process? Does it
> goes from runlevel 0 then 1, then 2 and then 3 or does it got straight
> to runlevel 3?
>
> 02. How is the runlevel transition during a clean shutdown process?
> Does it goes backwards passing through each intermediate runelevel,
> i.e. from 3 to 2, then 1, then 0 or does go straight to runlevel 0 (or
> 5)?
>
> 03. Generally speaking, if I am at runlevel X how does it transition to
> runlevel Y? For example, if I am at 3 how does goes to 1? Does it goes
> first to 2?
Why dont you follow the scripts on the UNIX version you are
working on presently ?
Start with the /etc/inittab file.
It has entries for the different runlevels ( the second field )
when you ask for a run level , say level 3, all the lines with
a run level of 3 in the second filed gets acted upon.
Then ofcourse Solaris 10 is different:, S10 uses the
System Management Facility , S10 only emulates runlevels
to be compatibel with what people and applications expect.
//Lars
|
|
0
|
|
|
|
Reply
|
tunla
|
7/31/2006 4:53:27 PM
|
|
Kamikaze wrote:
> Hello folks,
>
> I have been working with UNIXes/Solaris/Linux for a couple of years and
> I finally decided to read a little bit about runlevels, boot and
> shutdown process.
>
> I know how to work with it in practice, creating the init.d and rc.d
> scripts and sym links, yada, yada, yada, but let me see if you can help
> me to match my practice knowledge with the theory.
>
> 01. How are the runlevels transitions during a boot process? Does it
> goes from runlevel 0 then 1, then 2 and then 3 or does it got straight
> to runlevel 3?
>
> 02. How is the runlevel transition during a clean shutdown process?
> Does it goes backwards passing through each intermediate runelevel,
> i.e. from 3 to 2, then 1, then 0 or does go straight to runlevel 0 (or
> 5)?
>
> 03. Generally speaking, if I am at runlevel X how does it transition to
> runlevel Y? For example, if I am at 3 how does goes to 1? Does it goes
> first to 2?
>
>
> Thanks in advance and regards,
>
>
> PS: Sorry if I am not using the right terms.
>
If you understand shell scripts, you can look at /etc/inittab
and follow up each run-level yourself.
E.g. "init 0" command runs /sbin/rc0
which runs the K-scripts in /etc/rc0.d then the S-scripts,
then kills everything then umounts everything.
An "init 2" runs /sbin/rc2 which has a lot of if's to decide
what it must do.
I have never explored what really happens with manually
changing run levels.
For maintenance I reboot to single-user (rather than
finding out what is left after an "init S").
The boot procedure is more complicated.
Effectively it runs /etc/rcS.d S-scripts first, then
the S-scripts of 0, then 1, then 2, then 3.
--
Michael Tosch @ hp : com
|
|
0
|
|
|
|
Reply
|
Michael
|
7/31/2006 4:58:44 PM
|
|
Kamikaze wrote:
> Hello folks,
>
> I have been working with UNIXes/Solaris/Linux for a couple of years and
> I finally decided to read a little bit about runlevels, boot and
> shutdown process.
>
> I know how to work with it in practice, creating the init.d and rc.d
> scripts and sym links, yada, yada, yada, but let me see if you can help
> me to match my practice knowledge with the theory.
>
> 01. How are the runlevels transitions during a boot process? Does it
> goes from runlevel 0 then 1, then 2 and then 3 or does it got straight
> to runlevel 3?
There is something odd about runlevel 3 that I can't remember. It looks
like on boot you would first pass through runlevel 2 and then into
runlevel 3, but that is not really the case, and I don't remember what
is exactly happening.
> 02. How is the runlevel transition during a clean shutdown process?
> Does it goes backwards passing through each intermediate runelevel,
> i.e. from 3 to 2, then 1, then 0 or does go straight to runlevel 0 (or
> 5)?
You got straight to 0, 5 or 6 depending on what kind of shutdown you are
doing. So if there is an app that needs to be stopped, there needs to
be a kill script in rc0.d, rc5.d and rc6.d.
> 03. Generally speaking, if I am at runlevel X how does it transition to
> runlevel Y? For example, if I am at 3 how does goes to 1? Does it goes
> first to 2?
>
You don't step through the runlevels when switching. You just go to
that runlevel. What really happens is you execute /sbin/rcN where N is
the runlevel you want to be in, and those scripts just call all the K
and S scripts in the appropriate rcN.d directory.
This all sort of goes out the window with Solaris 10 and smf which is
more of a use case dependency diagram than distinct runlevels; though
there are "milestones" which mimic the functionality of a runlevel. The
READMEs in the various init.d and rc.d directories are very informative.
Neal
|
|
0
|
|
|
|
Reply
|
Neal
|
7/31/2006 5:00:58 PM
|
|
Michael Tosch wrote:
>
> The boot procedure is more complicated.
> Effectively it runs /etc/rcS.d S-scripts first, then
> the S-scripts of 0, then 1, then 2, then 3.
>
Reading /etc/rc3.d/README on Solaris 10, only rcS and rc2 scripts are run.
Neal
|
|
0
|
|
|
|
Reply
|
Neal
|
7/31/2006 5:04:24 PM
|
|
Neal A. Lucier <nlucier@math.purdue.edu> wrote:
>> 01. How are the runlevels transitions during a boot process? Does it
>> goes from runlevel 0 then 1, then 2 and then 3 or does it got straight
>> to runlevel 3?
For Solaris < 10:
/etc/inittab is read by init.
Any 'sysinit' lines are run
The 'default' runlevel is read from sysdef
The system goes to the default run level
So normally it executes sysinit, then '3'
> There is something odd about runlevel 3 that I can't remember. It looks
> like on boot you would first pass through runlevel 2 and then into
> runlevel 3, but that is not really the case, and I don't remember what
> is exactly happening.
It doesn't really "pass through" other runlevels. However in
/etc/inittab you can see that runlevel 3 will cause both rc2 and rc3 to
be executed (in that order).
Those scripts have additional logic that further complicates things.
The logic does different things depending on what run level the system
was in before.
--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
|
|
0
|
|
|
|
Reply
|
Darren
|
7/31/2006 5:28:35 PM
|
|
Guys,
I think Neal and Darren left it clear for me.
Yes, I am talking about Solaris 9, let's leave Solaris 10 for another
time.
So, during boot time the system goes directly to the default runlevel
defined in /etc/inittab:
is:3:initdefault:
I guess I had this wrong idea that to reach runlevel 3, the system
would have to "pass through" all other intermediate runlevels, maybe
because I knew that the services/daemons from runlevel 2 were also
running in runlevel 3, but this due to the fact that the runlevel 2
scripts are also run in the runlevel 3:
s2:23:wait:/sbin/rc2 >/dev/msglog 2<>/dev/msglog
</dev/console
During the shutdown, or any other runlevel transition, should be pretty
much the same. The system will go straight to the new runlevel, without
"passing through" any other intermediate runlevels (unless /etc/inittab
specify otherwise).
As we have more than one "shutdown exit runlevels (0, 5 and 6)", if we
want clean shutdown for an application, make sure you have a Kxx script
for all that levels.
(OBS: we do not need to discuss here the different shutdown (init 5,
init 6, halt, reboot, shutdown) scenarios, thanks)
I think that's was it.
Thanks a lot!
|
|
0
|
|
|
|
Reply
|
Kamikaze
|
7/31/2006 7:20:10 PM
|
|
Kamikaze <hugoksouza@gmail.com> wrote:
> As we have more than one "shutdown exit runlevels (0, 5 and 6)", if we
> want clean shutdown for an application, make sure you have a Kxx script
> for all that levels.
Sort of.
In this case, while each level is separate, and has a different name for
the script it runs (/sbin/rc[056]), each of these names is just a
different link to the same file:
So moving to any of those states runs the same scripts (in /etc/rc0.d).
$ grep 'rc.\.d' /sbin/rc[056]
/sbin/rc0:if [ -d /etc/rc0.d ]; then
/sbin/rc0: for f in /etc/rc0.d/K*; do
/sbin/rc0: for f in /etc/rc0.d/S*; do
/sbin/rc5:if [ -d /etc/rc0.d ]; then
/sbin/rc5: for f in /etc/rc0.d/K*; do
/sbin/rc5: for f in /etc/rc0.d/S*; do
/sbin/rc6:if [ -d /etc/rc0.d ]; then
/sbin/rc6: for f in /etc/rc0.d/K*; do
/sbin/rc6: for f in /etc/rc0.d/S*; do
--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
|
|
0
|
|
|
|
Reply
|
Darren
|
7/31/2006 9:15:48 PM
|
|
"Kamikaze" <hugoksouza@gmail.com> writes:
>I have been working with UNIXes/Solaris/Linux for a couple of years and
>I finally decided to read a little bit about runlevels, boot and
>shutdown process.
>I know how to work with it in practice, creating the init.d and rc.d
>scripts and sym links, yada, yada, yada, but let me see if you can help
>me to match my practice knowledge with the theory.
>01. How are the runlevels transitions during a boot process? Does it
>goes from runlevel 0 then 1, then 2 and then 3 or does it got straight
>to runlevel 3?
It goes directly to a specific run level; it does not transition
through the "intermediate" run-levels.
What the system actually does is described in /etc/inittab;
for Solaris 9 and before this is, for boot:
run the sysinit scripts:
ap::sysinit:/sbin/autopush -f /etc/iu.ap
ap::sysinit:/sbin/soconfig -f /etc/sock2path
fs::sysinit:/sbin/rcS sysinit
determine default runlevel:
is:3:initdefault:
then run the scripts/commands for runlevel 3:
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 ........ console .....
so it runs the:
rcS
rc2
rc3
scripts.
Forr each directory it will run the K* scripts and then the S* scripts,
in dictionary sort order.
>02. How is the runlevel transition during a clean shutdown process?
>Does it goes backwards passing through each intermediate runelevel,
>i.e. from 3 to 2, then 1, then 0 or does go straight to runlevel 0 (or
>5)?
No, it goes to a different run level and executes the script for that run
level; e.g., for "init 6" (reboot):
shutdown services using the rc6 script (runs scripts in /etc/rc0.d)
s6:6:wait:/sbin/rc6
and then reboot:
rb:6:wait:/sbin/uadmin 2 1
>03. Generally speaking, if I am at runlevel X how does it transition to
>runlevel Y? For example, if I am at 3 how does goes to 1? Does it goes
>first to 2?
No. There is no ordering in run levels.
Of course, with SMF this is all completely different and all services
are started according to the dependency graph.
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
|
|
0
|
|
|
|
Reply
|
Casper
|
8/1/2006 11:09:06 AM
|
|
"tunla" <lars.tunkrans@bredband.net> wrote in
> Then ofcourse Solaris 10 is different:, S10 uses the
> System Management Facility , S10 only emulates runlevels
> to be compatibel with what people and applications expect.
I am fairyl new to Solaris. Should one be avoiding editing ititab or
playing with directories such as /etc/rc3.d.
I need to start the "named" process - should I get SMF to do it for me?
--
Andrew Black
London
|
|
0
|
|
|
|
Reply
|
Andrew
|
8/1/2006 3:43:09 PM
|
|
On Tue, 1 Aug 2006, Andrew Black (delete obvious bit) wrote:
> I am fairyl new to Solaris. Should one be avoiding editing ititab or
> playing with directories such as /etc/rc3.d.
In SOlaris 10, yes unless it is necessary (not everything has been
migrated to using SMF yet).
> I need to start the "named" process - should I get SMF to do it for me?
Yes. Use "svcadm enable dns/server" once you've set up the configuration
files.
HTH,
--
Rich Teer, SCNA, SCSA, OpenSolaris CAB member
President,
Rite Online Inc.
Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
|
|
0
|
|
|
|
Reply
|
Rich
|
8/1/2006 3:56:27 PM
|
|
|
10 Replies
211 Views
(page loaded in 0.181 seconds)
Similiar Articles:7/14/2012 1:22:43 PM
|