This chapter provides guidelines for shutting down and booting a system and information about run levels and boot files.
This is a list of the step-by-step instructions in this chapter.
This is a list of overview information in this chapter.
A system's run level (also known as an init state) defines what services and resources are available to users. A system can be in only one run level at a time.
The Solaris environment has eight run levels, which are described in the following table. The default run level is specified in the /etc/inittab file as run level 3.
Table 8-1 Solaris Run Levels
Display run level information by using the who -r command to determine a system's run level.
$ who -r |
Use the who -r command to determine a system's current run level for any level except run level 0.
$ who -r . run-level 3 Sep 1 14:45 3 0 S $ |
run level 3 |
Identifies the current run level. |
Sep 1 14:45 |
Identifies the date of last run level change. |
3 |
Is the current run level. |
0 |
Identifies the number of times at this run level since the last reboot. |
S |
Identifies the previous run level. |
When you boot the system or change run levels with the init or shutdown command, the init daemon starts processes by reading information from the /etc/inittab file. This file defines three important items for the init process:
The system's default run level
What processes to start, monitor, and restart if they terminate
What actions to be taken when the system enters a new run level
Each entry in the /etc/inittab file has the following fields:
id:rstate:action:process
The following table describes the fields in an inittab entry.
Table 8-2 Fields in the inittab File
Field |
Description |
---|---|
id |
A unique identifier for the entry. |
rstate |
A list of run levels to which this entry applies. |
action |
How the process specified in the process field is to be run. Possible values include: initdefault, sysinit, boot, bootwait, wait, and respawn. |
process |
The command to execute. |
The following example shows an annotated default inittab file:
1 ap::sysinit:/sbin/autopush -f /etc/iu.ap 2 ap::sysinit:/sbin/soconfig -f /etc/sock2path 3 fs::sysinit:/sbin/rcS sysinit >/dev/msglog 2<>/dev/msglog </dev/console 4 is:3:initdefault: 5 p3:s1234:powerfail:/usr/sbin/shutdown -y -i5 -g0 >/dev/msglog 2<>/dev/... 6 sS:s:wait:/sbin/rcS >/dev/msglog 2<>/dev/msglog </dev/console 7 s0:0:wait:/sbin/rc0 >/dev/msglog 2<>/dev/msglog </dev/console 8 s1:1:respawn:/sbin/rc1 >/dev/msglog 2<>/dev/msglog </dev/console 9 s2:23:wait:/sbin/rc2 >/dev/msglog 2<>/dev/msglog </dev/console 10 s3:3:wait:/sbin/rc3 >/dev/msglog 2<>/dev/msglog </dev/console 11 s5:5:wait:/sbin/rc5 >/dev/msglog 2<>/dev/msglog </dev/console 12 s6:6:wait:/sbin/rc6 >/dev/msglog 2<>/dev/msglog </dev/console 13 fw:0:wait:/sbin/uadmin 2 0 >/dev/msglog 2<>/dev/msglog </dev/console 14 of:5:wait:/sbin/uadmin 2 6 >/dev/msglog 2<>/dev/msglog </dev/console 15 rb:6:wait:/sbin/uadmin 2 1 >/dev/msglog 2<>/dev/msglog </dev/console 16 sc:234:respawn:/usr/lib/saf/sac -t 300 17 co:234:respawn:/usr/lib/saf/ttymon -g -h -p "`uname -n` console login: " -T terminal-type -d /dev/console -l console -m ldterm,ttcompat |
Initializes STREAMS modules
Configures socket transport providers
Initializes file systems
Defines default run level
Describes a power fail shutdown
Defines single-user mode
Defines run level 0
Defines run level 1
Defines run level 2
Defines run level 3
Defines run level 5
Defines run level 6
Defines an unused level, firmware
Defines an unused level, off
Defines an unused level, reboot
Initializes Service Access Controller
Initializes console
The init process is started and reads the /etc/default/init file to set any environment variables. By default, only the TIMEZONE variable is set.
Then init reads the inittab file to do the following:
Identify the initdefault entry, which defines the default run level (3).
Execute any process entries that have sysinit in the action field so that any special initializations can take place before users login.
Execute any process entries that have 3 in the rstate field, which matches the default run level, 3.
See init(1M) for a detailed description of how the init process uses the inittab file.
The following table describes the key words used for run level 3's action field.
Table 8-3 Run Level 3 Action Key Word Descriptions
Key Word |
Starts the Specified Process ... |
---|---|
powerfail |
Only when the system receives a power fail signal. |
wait |
And waits for its termination. |
respawn |
If it does not exist. If the process already exists, continue scanning the inittab file. |
The following table describes the processes (or commands) executed at run level 3.
Table 8-4 Run Level 3 Command Descriptions
Command or Script Name |
Description |
---|---|
/usr/sbin/shutdown |
Shuts down the system. The init process runs the shutdown command only if the system has received a powerfail signal. |
/sbin/rcS |
Mounts and checks root (/), /usr, /var, and /var/adm file systems. |
/sbin/rc2 |
Starts the standard system processes, bringing the system up into run level 2 (multiuser mode). |
/sbin/rc3 |
Starts NFS resource sharing for run level 3. |
/usr/lib/saf/sac -t 30 |
Starts the port monitors and network access for UUCP. This process is restarted if it fails. |
/usr/lib/saf/ttymon -g -h -p "`uname -n` console login: " -T terminal_type -d /dev/console -l console |
Starts the ttymon process that monitors the console for login requests. This process is restarted if it fails. The terminal_type on a SPARC based system is sun The terminal_type on an IA based system is AT386 |
The Solaris software environment provides a detailed series of run control (rc) scripts to control run level changes. Each run level has an associated rc script located in the /sbin directory:
rc0
rc1
rc2
rc3
rc5
rc6
rcS
For each rc script in the /sbin directory, there is a corresponding directory named /etc/rcn.d that contains scripts to perform various actions for that run level. For example, /etc/rc2.d contains files used to start and stop processes for run level 2.
# ls /etc/rc2.d K07dmi S70uucp S75cron S91afbinit K07snmpdx S71ldap.client S75flashprom S91ifbinit K28nfs.server S71rpc S75savecore S92volmgt README S71sysid.sys S76nscd S93cacheos.finish S01MOUNTFSYS S72autoinstall S80PRESERVE S94ncalogd S05RMTMPFILES S72inetsvc S80lp S95IIim S20sysetup S72slpd S80spc S95amiserv S21perf S73cachefs.daemon S85power S95ocfserv S30sysid.net S73nfs.client S88sendmail S99audit S40llc2 S74autofs S88utmpd S99dtlogin S47asppp S74syslog S89bdconfig S69inet S74xntpd S90wbem |
The /etc/rcn.d scripts are always run in ASCII sort order. The scripts have names of the form:
[KS][0-9][0-9]*
Files beginning with K are run to terminate (kill) a system process. Files beginning with S are run to start a system process.
Run control scripts are also located in the /etc/init.d directory. These files are linked to corresponding run control scripts in the /etc/rcn.d directories.
The actions of each run control script are summarized in Table 8-5.
One advantage of having individual scripts for each run level is that you can run scripts in the /etc/init.d directory individually to turn off functionality without changing a system's run level.
Become superuser.
Turn off functionality.
# /etc/init.d/filename stop |
Restart functionality.
# /etc/init.d/filename start |
Use the pgrep command to verify whether the service has been stopped or started.
# pgrep -f service |
Turn off NFS server functionality by typing:
# /etc/init.d/nfs.server stop # pgrep -f nfs # |
Restart the NFS services by typing:
# /etc/init.d/nfs.server start # pgrep -f nfs 141 143 245 247 # pgrep -f nfs -d, | xargs ps -fp daemon 141 1 40 Jul 31 ? 0:00 /usr/lib/nfs/statd root 143 1 80 Jul 31 ? 0:01 /usr/lib/nfs/lockd root 245 1 34 Jul 31 ? 0:00 /usr/lib/nfs/nfsd -a 16 root 247 1 80 Jul 31 ? 0:02 /usr/lib/nfs/mountd |
If you want to add a run control script to start and stop a service, copy the script into the /etc/init.d directory and create links in the rcn.d directory you want the service to start and stop.
See the README file in each /etc/rcn.d directory for more information on naming run control scripts. The procedure below describes how to add a run control script.
Become superuser.
Add the script to the /etc/init.d directory.
# cp filename /etc/init.d # chmod 0744 /etc/init.d/filename # chown root:sys /etc/init.d/filename |
Create links to the appropriate rcn.d directory.
# cd /etc/init.d # ln filename /etc/rc2.d/Snnfilename # ln filename /etc/rcn.d/Knnfilename |
Use the ls command to verify that the script has links in the specified directories.
# ls /etc/init.d/ /etc/rc2.d/ /etc/rcn.d/ |
# cp xyz /etc/init.d # cd /etc/init.d # ln xyz /etc/rc2.d/S100xyz # ln xyz /etc/rc0.d/K100xyz # ls /etc/init.d /etc/rc2.d /etc/rc0.d |
Disable a run control script by renaming it with a dot (.) at the beginning of the new file name. Files that begin with a dot are not executed. If you copy a file by adding a suffix to it, both files will be run.
Become superuser.
Rename the script by adding an underscore (_) to the beginning of the new file.
# cd /etc/rcn.d # mv filename _filename |
Verify the script has been renamed.
# ls # _filename |
The following example changes the S100datainit script name but saves the original script.
# cd /etc/rc2.d # mv S100datainit _S100datainit |
Script Name |
Description |
---|---|
/sbin/rc0 |
Performs the following tasks: |
|
|
Table 8-6 The /sbin/rc1 Script
Table 8-7 The /sbin/rc2 Script
Many of the system services and applications that are started at run level 2 depend on what software is installed on the system.
Table 8-9 The /sbin/rc5 and /sbin/rc6 Scripts
Script Name |
Description |
---|---|
/sbin/rc5 and /sbin/rc6 |
Runs the /etc/rc0.d/K* scripts to perform the following tasks: |
|
|
Table 8-10 The /sbin/rcS Script