内に含ま
その他のドキュメント
サポート リソース
| PDF 文書ファイルをダウンロードする
Run Levels and Boot Files
6
- 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.
-
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 software environment has eight run levels, which are described in Table 6-1. The default run level 3 is specified in the /etc/inittab file.
-
Table 6-1
| Run Level | Init State | Type | Use This Level ... |
| 0 | Power-down state | Power-down | To shut down the operating system so that it is safe to turn off power to the system. |
| 1 | Administrative state | Single-user | To access all available file systems with user logins allowed. The terminal from which you issue this command becomes the Console. |
| 2 | Multiuser state | Multiuser | For normal operations. Multiple users can access the system and the entire file system. All daemons are running except for NFS server and syslog. |
| 3 | Multiuser with NFS resources shared | Multiuser | For normal operations with NFS resource-sharing available. |
| 4 | Alternative multiuser state | This level is currently unavailable. |
| 5 | 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 turn off system power on systems that support this feature. |
| 6 | Reboot state | Reboot | To shut down the system to run level 0, and then reboot to multiuser state (or whatever level is the default in the inittab file). |
| s or S | Single-user state | Single-user | To run as a single user with all file systems mounted and accessible. |
· How to Determine a System's Run Level
- Display run level information by using the who -r command to determine a system's run level.
-
- 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
-
$ who -r
. run-level 3 Oct 26 15:04 3 0 S
$
|
- In this example,
-
-
run level 3 Identifies the current run level.
Oct 26 15:04 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. |
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:
-
- 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
-
Table 6-2 describes the fields in an inittab entry.
-
Table 6-2 inittab
| Field | Description |
| id | A unique identifier for the entry. |
| rstate | The run level, which corresponds to the command or (script) to be processed. |
| action | How the process specified in the process field is to be run. |
| process | The name of the process (or command) to execute. |
Example--Default inittab File
- The following example shows an annotated default inittab file:
-
1 ap::sysinit:/sbin/autopush -f /etc/iu.ap
2 fs::sysinit:/sbin/bcheckrc >/dev/console 2>&1 </dev/console
3 is:3:initdefault:
4 p3:s1234:powerfail:/sbin/shutdown -y -i0 -g0 >/dev/console 2>&1 </dev/console
5 s0:0:wait:/sbin/rc0 off >/dev/console 2>&1 </dev/console
6 s1:1:wait:/sbin/shutdown -y -iS -g0 >/dev/console 2>&1 </dev/console
7 s2:23:wait:/sbin/rc2 >/dev/console 2>&1 </dev/console
8 s3:3:wait:/sbin/rc3 >/dev/console 2>&1 </dev/console
9 s5:5:wait:/sbin/rc5 ask >/dev/console 2>&1 </dev/console
10 s6:6:wait:/sbin/rc6 reboot >/dev/console 2>&1 </dev/console
11 of:0:wait:/sbin/uadmin 2 0 >/dev/console 2>&1 </dev/console
12 fw:5:wait:/sbin/uadmin 2 2 >/dev/console 2>&1 </dev/console
13 RB:6:wait:/sbin/sh -c 'echo "\nThe system is being restarted."' >/dev/console 2>&1
14 rb:6:wait:/sbin/uadmin 2 1 >/dev/console 2>&1 </dev/console
15 sc:234:respawn:/usr/lib/saf/sac -t 300
16 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
- STREAMS module initialization
-
2
- File system check
-
3
- Default run level
-
4
- Power fail shutdown
-
5
- Run level 0
-
6
- Run level 1
-
7
- Run level 2
-
8
- Run level 3
-
9
- Run level 5
-
10
- Run level 6
-
11
- Off
-
12
- Firmware
-
13
- Reboot
-
14
- Reboot single-user
-
15
- Service access controller initialization
-
16
- Console initialization
What Happens When the System is Brought to Run Level 3
-
- 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:
a. Identify the initdefault entry, which defines the default run level (3). b. Execute any process entries that have sysinit in the action field so that any special initializations can take place before users login. c. 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.
-
Table 6-3 describes the key words used for run level 3's action field.
-
Table 6-3
| 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. |
-
Table 6-4 describes the processes (or commands) executed at run level 3.
-
Table 6-4
| 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/rc2 | Sets up the time zone, then 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 system is sun The terminal_type on a x86 system is AT386 |
Run Control Scripts
- 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
K20lp S30sysid.net S74autofs S88sendmail
K20spc S69inet S74syslog S88utmpd
K60nfs.server S71rpc S75cron S92volmgt
README S71sysid.sys S76nscd S93cacheos.finish
S01MOUNTFSYS S72autoinstall S80PRESERVE S99audit
S05RMTMPFILES S72inetsvc S80lp
S20sysetup S73nfs.client S80spc
#
|
- The /etc/rcn.d scripts are always run in ASCII sort order. The scripts have names of the form:
- [K,S][0-9][0-9][A-Z][0-99]
- 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/rc*.d directories.
- The actions of each run control script are summarized in Table 6-5 through Table 6-11, starting on page 129.
Using a Run Control Script to Stop or Start Services
- 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.
· How to Use a Run Control Script to Stop or Start a Service
-
-
Become root.
-
Turn off functionality.
-
# /etc/init.d/filename stop
|
-
-
Restart functionality.
-
# /etc/init.d/filename start
|
Verification--Using a Run Control Script to Stop or Start a Service
- Use the ps and grep commands to identify whether the service has been stopped or started.
-
Example--Using a Run Control Script to Stop or Start a Service
- Turn off NFS server functionality by typing:
-
# /etc/init.d/nfs.server stop
# ps -ef | grep nfs
|
- Restart the NFS services by typing:
-
# /etc/init.d/nfs.server start
# ps -ef | grep nfs
root 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
root 1324 1318 11 13:29:52 pts/0 0:00 grep nfs
|
Adding a Run Control Script
- 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 rc*.d directory you want the service to start and stop.
- See the README file in each /etc/rc*.d directory for more information on naming run control scripts. The procedure below describes how to add a run control script.
· How to Add a Run Control Script
-
-
Become root.
-
Add the script to the /etc/init.d directory.
-
# cp filename /etc/init.d
|
-
-
Create links to the appropriate rc*.d directory.
-
# cd /etc/init.d
# ln filename /etc/rc2.d/Snnfilename
# ln filename /etc/rcn.d/Knnfilename
|
Verification--Adding a Run Control Script
- Use the ls command to verify that the script has links in the specified directories.
-
# ls /etc/init.d/filename /etc/rc2.d/Snnfilename /etc/rcn.d/Knnfilename
/etc/init.d/filea /etc/rc2.d/Snnfilename /etc/rcn.d/Knnfilename
|
Example--Adding a Run Control Script
-
# cp xyz /etc/init.d
# cd /etc/init.d
# ln xyz /etc/rc2.d/S100xyz
# ln xyz /etc/rc0.d/K100xyz
|
Disabling a Run Control Script
- 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.
· How to Disable a Run Control Script
-
-
Become root.
-
Rename the script by adding a dot (.) to the beginning of the new file.
-
# cd /etc/rcn.d
# cp filename .filename
|
Example--Disabling a Run Control Script
- The following example changes the K00ANNOUNCE script name but saves the original script.
-
# cd /etc/rc0.d
# cp K00ANNOUNCE .K00ANNOUNCE
|
Run Control Script Summaries
-
Table 6-5 summarizes the /sbin/rc0 script.
-
Table 6-5 /sbin/rc0
| Script Name | Description |
| /sbin/rc0 | Performs the following tasks:
· Stops system services and daemons
· Terminates all running processes
· Unmounts all file systems |
-
Table 6-6 summarizes the /sbin/rc1 script.
-
Table 6-6 /sbin/rc1
| Script Name | Description |
| /sbin/rc1 | Runs the /etc/rc1.d scripts to perform the following tasks:
· Stops system services and daemons
· Terminates all running processes
· Unmounts all file systems
· Brings the system up in single-user mode |
-
Table 6-7 summarizes the /sbin/rc2 script.
-
Table 6-7 /sbin/rc2
| Script Name | Description |
| /sbin/rc2 | Runs the /etc/rc2.d scripts to perform the following tasks:
· Mounts all local file systems · Enables disk quotas if at least one file system was mounted with the quota option · Saves editor temporary files in /usr/preserve · Removes any files in the /tmp directory · Rebuilds device entries for reconfiguration boots · Configures system accounting · Configures default router · Sets NIS domain and ifconfig netmask · Reboots the system from the installation media or a boot server if either /.PREINSTALL or /AUTOINSTALL exists · Starts inetd and rpcbind and named, if appropriate · Starts Kerberos client-side daemon, kerbd · Starts NIS daemons (ypbind) and NIS+ daemons (rpc.nisd), depending on whether the system is configured for NIS or NIS+, and whether the system is a client or a server · Starts keyserv, statd, lockd, and utmpd · Mounts all NFS entries · Starts ncsd (name service cache daemon) · Starts automount, cron, LP, sendmail, utmpd, and vold daemons
|
-
Note - Many of the system services and applications that are started at run level 2 depend on what software is installed on the system.
-
Table 6-8 summarizes the /sbin/rc3 script.
-
Table 6-8 /sbin/rc3
| Script Name | Description |
| /sbin/rc3 | Runs the /etc/rc3.d scripts to perform the following tasks:
· Cleans up sharetab · Starts nfsds · Starts mountd · If boot server, starts rarpd, rpc.bootparamd, and rpld
|
-
Table 6-9 summarizes the /sbin/rc5 script.
-
Table 6-9 /sbin/rc5
| Script Name | Description |
| /sbin/rc5 | Runs the /etc/rc0.d scripts to perform the following tasks:
· Kills the printer and syslog daemons · Unmounts local and remote file systems · Stops NFS server and client services · Stops NIS, RPC, and cron services Kills all active processes and initiates an interactive boot
|
-
Table 6-10 summarizes the /sbin/rc6 script.
-
Table 6-10 /sbin/rc6
| Script Name | Description |
| /sbin/rc6 | Performs the following tasks:
· Runs the /etc/rc0.d/K* scripts to stop system processes · Kills all active processes · Unmounts the file systems · Runs the initdefault entries in the /etc/inittab file.
|
-
Table 6-11 summarizes the /sbin/rcS script.
-
Table 6-11 /sbin/rcS
| Script Name | Description |
| /sbin/rcS | Runs the /etc/rcS.d scripts to bring the system up to run level S. The following tasks are performed from these scripts:
· Establishes a minimal network · Mounts /usr, if necessary · Sets the system name · Checks the root (/) and /usr file systems · 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 mode
|
|
|