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.
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.
$ who -r |
Use the who -r command to determine a system's current run level for any level, except run level 0.
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 $ |
Identifies the current run level
Identifies the date of last run level change
Also identifies the current run level
Identifies the number of times the system has been at this run level since the last reboot
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 take 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 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. |
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 |
Initializes STREAMS modules
Configures socket transport providers
Initializes file systems
Defines default run level
Describes a power fail shutdown
Defines single-user level
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 and identifies the terminal type
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 and does the following:
Identifies the initdefault entry, which defines the default run level (3).
Executes any process entries that have sysinit in the action field so that any special initializations can take place before users login.
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 8–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 8–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. |
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:
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 that are used to start and stop processes for run level 2.
# ls /etc/rc2.d K03samba* S05RMTMPFILES* S72inetsvc* S88utmpd* K03sshd* S10lu* S72slpd* S89PRESERVE* K05appserv* S20sysetup* S73cachefs.daemon* S89bdconfig@ K05volmgt* S21perf* S73nfs.client* S90wbem* K06mipagent* S30sysid.net* S74autofs* S91zuluinit* K07dmi* S40llc2* S74syslog* S93cacheos.finish* K07snmpdx* S42ncakmod* S74xntpd* S94ncalogd* K15imq* S47pppd* S75cron* S95IIim* K16apache* S69inet* S75flashprom* S95svm.sync* K21dhcp* S70sckm* S75savecore* S98efcode* K27boot.server* S70uucp* S76nscd* S99audit* K28kdc* S71ldap.client* S77sf880dr* S99dtlogin* K28kdc.master* S71rpc* S80lp* S99emul64* K28nfs.server* S71sysid.sys* S80spc* S99rcapd* README S72autoinstall* S85power* S01MOUNTFSYS* S72directory* S88sendmail* |
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.
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 runs the /etc/rc0.d scripts to perform the following tasks:
Stops system services and daemons
Terminates all running processes
Unmounts all file systems
The /sbin/rc1 script runs the /etc/rc1.d scripts to perform the following tasks:
Stops system services and daemons
Terminates all running user processes
Unmounts all remote file systems
Mounts all local file systems if the previous run level was S
The /sbin/rc2 script runs the /etc/rc2.d scripts to perform the following tasks, grouped by function:
Local system-related tasks:
Mounts all local file systems if the previous run level was S
Enables disk quotas if at least one file system was mounted with the quota option
Saves temporary editor files in the /usr/preserve directory
Removes any files and subdirectories in the /tmp directory
Starts system activity data collecting, system accounting, and system auditing, if configured
Starts the system logging daemon (syslogd), sets the default dump device, and rotates the /var/adm/messages file
Sets the default scheduling class if the /etc/dispadmin.conf file exists
Starts LP print service (lpsched) if a local printer is configured and cleans up the print queue
Configures power management, if appropriate
Starts the utmpd daemon
Starts the cron and vold daemons
Configures serial device stream
Configures WBEM services
Syncs volumes, if required, and starts the mdmonitord daemon to monitor the physical components of the volumes
Starts the CDE desktop login process, dtlogin, if appropriate
Network service or security-related tasks:
Configures the network interfaces, sets ifconfig netmask, and configures network routing, if appropriate
Starts network service (inetd and rpcbind) daemons
Starts the logical link controller (llc2), if configured
Sets the name service domain name, starts various name services daemons, depending on if the system is configured for a name service, and whether the system is a client or a server
Starts the keyserv, statd, lockd, and xntpd daemons, if appropriate
Mounts all NFS entries
Configures the Solaris Network Cache and Accelerator (NCA) and NCA logging, if appropriate
Starts the Solaris PPP server or client daemons (pppoed or pppd), if configured
Starts LDAP cache manager (ldap_cachemgr), if configured
Starts directory server (slapd) daemon, if configured
Starts DNS (in.named) daemon, if configured
Starts Service Location Protocol (slpd) daemon, if configured
Configures system resource controls and system pools if the /etc/rctladm.conf and /etc/pooladm.conf files exist
Starts the cachefsd, automount, and sendmail daemons, if appropriate
Starts the htt_server process
Install-related tasks:
Configures the boot environment for the Live Upgrade software upon system startup or system shutdown
Checks for the presence of the /etc/.UNCONFIGURE file to see if the system should be reconfigured
Reboots the system from the installation media or a boot server if either /.PREINSTALL or /AUTOINSTALL exists
Hardware-related tasks:
Starts the Sun Fire 15000 key management daemon (sckmd), if appropriate
Starts the Sun Fire 880 Dynamic Reconfiguration daemon (sf880drd), if appropriate
Runs the flash PROM update script
Configures any graphic frame buffers or graphic accelerators
Runs the FCode interpreter daemon (efdaemon), if necessary
Transitions the following services between run-level changes:
Apache (tomcat)
Boot server (in.rarpd), (rpc.bootparamd), or (rpld)
DHCP (in.dhcpd)
Kerberos KDC (krb5kdc ) and Kerberos administration (kadmind)
Mobile IP (mipagent)
NFS server (nfsd), (mountd), (nfslogd)
Samba (smdb) and (nmdb)
Secure shell (sshd)
Solstice Enterprise Agents (dmispd) and (snmpXdmid)
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 runs the /etc/rc3.d scripts to perform the following tasks:
Starts the Apache server daemon (tomcat), if configured
Starts the DHCP daemon (in.dhcpd), if appropriate
Starts Kerberos KDC (krb5kdc) and Kerberos administration (kadmind) daemons, if configured
Starts Mobile IP daemon (mipagent), if configured
Starts the Samba daemons (smdb and nmdb), if configured
Starts the secure shell daemon (sshd), if appropriate
Starts the Solstice Enterprise Agents (dmispd and snmpXdmid)
Cleans up the /etc/dfs/sharetab file
Starts the NFS server daemons nfsd, mountd, and nfslogd, if appropriate
If the system is a boot server, starts the rarpd, rpc.bootparamd, and rpld daemons
The /sbin/rc5 and /sbin/rc6 scripts run the /etc/rc0.d/K* scripts to perform the following tasks:
Kills all active processes
Unmounts the file systems
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:
Establishes a minimal network
Checks and mounts root (/), /usr, /tmp, /var, /var/adm, and /var/run file systems.
Sets the system name
Mounts pseudo file systems (/proc and /dev/fd)
Rebuilds the device entries for reconfiguration boots
Checks and mounts other file systems to be mounted in single-user level
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.
Become superuser.
Stop the system service.
# /etc/init.d/filename stop |
Restart the system service.
# /etc/init.d/filename start |
Verify that the service has been stopped or started.
# pgrep -f 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 |
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.
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 |
Verify that the script has links in the specified directories.
# ls /etc/init.d/ /etc/rc2.d/ /etc/rcn.d/ |
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 |
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.
Become superuser.
Rename the script by adding an underscore (_) to the beginning of the new file.
# cd /etc/rcn.d # mv filename _filename |
Verify that the script has been renamed.
# ls _* # _filename |
The following example shows how to rename the S100datainit script.
# cd /etc/rc2.d # mv S100datainit _S100datainit # ls _* # _S100datainit |
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 8–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. |