System Administration Guide: Basic Administration

Chapter 11 Run Levels and Boot Files (Tasks)

This chapter provides overview information and tasks that are related to run levels and boot files.

This is a list of the step-by-step instructions in this chapter.

This is a list of the overview information in this chapter.

Run Levels

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 11–1 Solaris Run Levels

Run Level 

Init State 

Type 

Purpose 

Power-down state 

Power-down 

 

To shut down the operating system so that it is safe to turn off power to the system.

s or S

Single-user state

Single-user 

To run as a single user with some file systems mounted and accessible.  

Administrative state 

Single-user 

To access all available file systems. User logins are disabled.

Multiuser state 

Multiuser 

For normal operations. Multiple users can access the system and all file system. All daemons are running except for the NFS server daemons.

Multiuser level with NFS resources shared

Multiuser 

For normal operations with NFS resources shared. This is the default run level for the Solaris environment.

Alternative multiuser state 

 

Currently unavailable. 

Power-down state 

Power-down 

To shut down the operating system so that it is safe to turn off power to the system. If possible, automatically turns off power on systems that support this feature. 

Reboot state 

Reboot 

To shut down the system to run level 0, and then reboot to multiuser level with NFS resources shared (or whatever level is the default in the inittab file).

How to Determine a System's Run Level

Display run level information by using the who -r command.


$ who -r

Use the who -r command to determine a system's current run level for any level, except run level 0.

Example—Determining a System's Run Level

This example displays information a system's current run level and information about previous run levels.


$ who -r
 .    run-level 31  Dec 13 10:102   33   04 S5
$
  1. Identifies the current run level

  2. Identifies the date of last run level change

  3. Also identifies the current run level

  4. Identifies the number of times the system has been at this run level since the last reboot

  5. Identifies the previous run level

The /etc/inittab File

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:

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 11–2 Fields Descriptions for the inittab File

Field 

Description 

id

Is a unique identifier for the entry. 

rstate

Lists the run levels to which this entry applies. 

action

Identifies how the process that is specified in the process field is to be run. Possible values include: initdefault, sysinit, boot, bootwait, wait, and respawn.

initdefault identifies the default run level. For a description of the other action keywords, see inittab(4).

process

Defines the command or script to execute. 

Example—Default inittab File

The following example shows an annotated default inittab file that is installed with the Solaris release:


 

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  
  1. Initializes STREAMS modules

  2. Configures socket transport providers

  3. Initializes file systems

  4. Defines default run level

  5. Describes a power fail shutdown

  6. Defines single-user level

  7. Defines run level 0

  8. Defines run level 1

  9. Defines run level 2

  10. Defines run level 3

  11. Defines run level 5

  12. Defines run level 6

  13. Defines an unused level, firmware

  14. Defines an unused level, off

  15. Defines an unused level, reboot

  16. Initializes Service Access Controller

  17. Initializes console and identifies the terminal type

What Happens When the System Is Brought to Run Level 3

  1. 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.

  2. Then init reads the inittab file and does the following:

    1. Identifies the initdefault entry, which defines the default run level (3).

    2. Executes any process entries that have sysinit in the action field so that any special initializations can take place before users login.

    3. Executes any process entries that have a 3 in the rstate field, which matches the default run level, 3.

      For a detailed description of how the init process uses the inittab file, see init(1M).

The following table describes the keywords used for run level 3's action field.

Table 11–3 Run Level 3 Action Keyword Descriptions

Key Word 

Description 

powerfail

Starts the process when the init process receives a power failure signal

respawn

Starts the process and restarts it when it dies 

wait

Starts the process and waits for it to finish before going on to the next entry for this run level 

The following table describes the processes (or commands) that are executed at run level 3.

Table 11–4 Command Descriptions for Run Level 3

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 power fail signal.

/sbin/rcS

Checks and mounts root (/), /usr, /tmp, /var, /var/adm, and /var/run file systems.

/sbin/rc2

Starts the standard system processes and brings the system up into run level 2 (multiuser level). 

/sbin/rc3

Starts NFS resource sharing for run level 3. 

/usr/lib/saf/sac -t 30

Starts the port monitors. 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 x86 based system is AT386.

Run Control Scripts


Note –

The way system services are started and stopped in the Solaris environment might change in some future release.


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 that is located in the /sbin directory:

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 that are used to start and stop processes for run level 2.


# ls /etc/rc2.d
K03samba*          S20sysetup*        S72slpd*            S88utmpd*
K06mipagent*       S21perf*           S73cachefs.daemon*  S89PRESERVE*
K07dmi*            S30sysid.net*      S73nfs.client*      S89bdconfig@
K07snmpdx*         S40llc2*           S74autofs*          S90wbem*
K16apache*         S42ncakmod*        S74syslog*          S91afbinit*
K21dhcp*           S47pppd*           S74xntpd*           S91gfbinit*
K26sshd*           S69inet*           S75cron*            S91ifbinit*
K27boot.server*    S70sckm*           S75flashprom*       S92volmgt*
K28kdc*            S70uucp*           S75savecore*        S93cacheos.finish*
K28kdc.master*     S71ldap.client*    S76nscd*            S94ncalogd*
K28nfs.server*     S71rpc*            S77sf880dr*         S95IIim*
README             S71sysid.sys*      S80lp*              S95svm.sync*
S01MOUNTFSYS*      S72autoinstall*    S80spc*             S98efcode*
S05RMTMPFILES*     S72directory@      S85power*           S99audit*
S10lu*             S72inetsvc*        S88sendmail*        S99dtlogin*

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 that begin with K are run to terminate (kill) a system service. Files that begin with S are run to start a system service.

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 the following section.

Run Control Script Summaries

The following sections summarize the run control scripts that are used to start and stop system services when you change run levels.

The /sbin/rc0 Script

The /sbin/rc0 script runs the /etc/rc0.d scripts to perform the following tasks:

The /sbin/rc1 Script

The /sbin/rc1 script runs the /etc/rc1.d scripts to perform the following tasks:

The /sbin/rc2 Script

The /sbin/rc2 script runs the /etc/rc2.d scripts to perform the following tasks, grouped by function:

Local system-related tasks:

Network service or security-related tasks:

Install-related tasks:

Hardware-related tasks:

Transitions the following services between run-level changes:


Note –

Many of the system services and applications that are started at run level 2 depend on what software is installed on the system.


The /sbin/rc3 Script

The /sbin/rc3 script runs the /etc/rc3.d scripts to perform the following tasks:

The /sbin/rc5 and /sbin/rc6 Scripts

The /sbin/rc5 and /sbin/rc6 scripts run the /etc/rc0.d/K* scripts to perform the following tasks:

The /sbin/rcS Script

The /sbin/rcS script runs the /etc/rcS.d scripts to bring the system up to run level S. The following tasks are performed by these scripts:

Using a Run Control Script to Stop or Start Services


Note –

The way system services are started and stopped in Solaris environment might change in some future release.


One advantage of having individual scripts for each run level is that you can run scripts in the /etc/init.d directory individually to stop system services without changing a system's run level.

How to Use a Run Control Script to Stop or Start a Service

  1. Become superuser.

  2. Stop the system service.


    # /etc/init.d/filename stop
    
  3. Restart the system service.


    # /etc/init.d/filename start
    
  4. Verify that the service has been stopped or started.


    # pgrep -f service
    

Example—Using a Run Control Script to Stop or Start a Service

For example, you can stop the NFS server daemons by typing the following:


# /etc/init.d/nfs.server stop
# pgrep -f nfs
#

Then, you can restart the NFS server daemons by typing the following:


# /etc/init.d/nfs.server start
# pgrep -f nfs 
341
343
347
345
# pgrep -f nfs -d, | xargs ps -fp
 UID   PID  PPID  C    STIME TTY      TIME CMD
  daemon   341     1  0   Aug 21 ?        0:00 /usr/lib/nfs/statd
    root   343     1  0   Aug 21 ?        0:00 /usr/lib/nfs/lockd
    root   347     1  0   Aug 21 ?        0:41 /usr/lib/nfs/nfsd
    root   345     1  0   Aug 21 ?        0:02 /usr/lib/nfs/mountd

Adding a Run Control Script


Note –

The way system services are started and stopped in the Solaris environment might change in some future release.


If you want to add a run control script to start and stop a service, copy the script into the /etc/init.d directory. Then, create links in the rcn.d directory where 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 following procedure describes how to add a run control script.

How to Add a Run Control Script

  1. Become superuser.

  2. 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
    
  3. Create links to the appropriate rcn.d directory.


    # cd /etc/init.d
    # ln filename /etc/rc2.d/Snnfilename
    # ln filename /etc/rcn.d/Knnfilename
    
  4. Verify that the script has links in the specified directories.


    # ls /etc/init.d/ /etc/rc2.d/ /etc/rcn.d/
    

Example—Adding a Run Control Script

The following example shows how to add a run control script for the xyz service.


# cp xyz /etc/init.d
# chmod 0744 /etc/init.d/xyz
# chown root:sys /etc/init.d/xyz
# 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

Disabling a Run Control Script

You can disable a run control script by renaming it with an underscore (_) at the beginning of the file name. Files that begin with an underscore or dot are not executed. If you copy a file by adding a suffix to it, both files will be run.

How to Disable a Run Control Script

  1. Become superuser.

  2. Rename the script by adding an underscore (_) to the beginning of the new file.


    # cd /etc/rcn.d
    # mv filename _filename
    
  3. Verify that the script has been renamed.


    # ls _*
    # _filename
    

Example—Disabling a Run Control Script

The following example shows how to rename the S100datainit script.


# cd /etc/rc2.d
# mv S100datainit _S100datainit
# ls _*
# _S100datainit

x86: Boot Files

In addition to the run control scripts and boot files described previously, there are additional boot files that are associated with booting a Solaris x86 system.

Table 11–5 x86: Boot Files

File 

Description 

/etc/bootrc

Contains menus and options for booting the Solaris release. 

/boot

Contains files and directories needed to boot the system. 

/boot/mdboot

DOS executable that loads the first-level bootstrap program (strap.com) into memory from disk.

/boot/mdbootbp

DOS executable that loads the first-level bootstrap program (strap.com) into memory from diskette.

/boot/rc.d

Directory that contains install scripts. Do not modify the contents of this directory. 

/boot/solaris

Directory that contains items for the boot subsystem. 

/boot/solaris/boot.bin

Loads the Solaris kernel or standalone kadb. In addition, this executable provides some boot firmware services.

/boot/solaris/boot.rc

Prints the Solaris x86 Platform Edition and runs the Device Configuration Assistant in DOS-emulation mode. 

/boot/solaris/bootconf.exe

DOS executable for the Device Configuration Assistant. 

/boot/solaris/bootconf.txt

Text file that contains internationalized messages for Device Configuration Assistant (bootconf.exe).

/boot/solaris/bootenv.rc

Stores eeprom variables that are used to set up the boot environment.  

/boot/solaris/devicedb

Directory that contains the master file, a database of all possible devices supported with realmode drivers.

/boot/solaris/drivers

Directory that contains realmode drivers. 

/boot/solaris/itup2.exe

DOS executable run during install time update (ITU) process.  

/boot/solaris/machines

Obsolete directory. 

/boot/solaris/nbp

File associated with network booting. 

/boot/solaris/strap.rc

File that contains instructions on what load module to load and where in memory it should be loaded. 

/boot/strap.com

DOS executable that loads the second-level bootstrap program into memory.