How Run Levels Work
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.
Oracle Solaris 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 4-1 Oracle Solaris
Run Levels | | | |
0
| Power-down state
| Power-down
| To shut down the operating system
so that it is safe to turn off power to the system.
|
|
| Single-user
| To run as a single user with some file systems mounted and accessible.
|
1
| Administrative state
| Single-user
| To access all available file systems.
User logins are disabled.
|
2
| Multiuser state
| Multiuser
| For normal operations. Multiple users
can access the system and all file systems. All daemons are running except
for the NFS server daemons.
|
3
| Multiuser level with NFS resources shared
| Multiuser
| For normal operations with NFS
resources shared. This is the default run level.
|
4
| Alternative multiuser state
| Multiuser
| Not configured by default, but available for customer use.
|
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 turns off power on systems that
support this feature.
|
6
| Reboot state
| Reboot
| To stop the operating system and reboot to the state that is defined
by the initdefault entry in the /etc/inittab file. The SMF service, svc:/system/boot-config:default,
is enabled by default. When the config/fastreboot_default property
is set to true, init 6 bypasses certain firmware initialization
and test steps, depending on the specific capabilities of the system. See Accelerating the Reboot Process.
|
|
In addition, the svcadm command can be used to change
the run level of a system, by selecting a milestone at which to run. The following
table shows which run level corresponds to each milestone.
Table 4-2 Run Levels and SMF Milestones | |
S
| milestone/single-user:default
|
2
| milestone/multi-user:default
|
3
| milestone/multi-user-server:default
|
|
What Happens When a System Is Booted to a
Multiuser State (Run Level 3)
The init process is started and reads the
properties defined in the svc:/system/environment:init SMF
service to set any environment variables. By default, only the TIMEZONE variable
is set.
Then, init reads the inittab file
and does the following:
Executes any process entries that have sysinit in
the action field so that any special initializations can
take place before users log in to the system.
Passes the startup activities to svc.startd.
For a detailed description of how the init process uses the inittab file, see the init(1M) man page.
When to Use Run Levels or Milestones
In general, changing milestones or run levels is an uncommon procedure.
If it is necessary, using the init command to change to
a run level will change the milestone as well and is the appropriate command
to use. The init command is also good for shutting down
a system.
However, booting a system using the none milestone can be very useful for
debugging startup problems. There is no equivalent run level to the none
milestone. For more information, see How to Investigate Problems Starting Services at System Boot in Managing System Services in Oracle Solaris 11.2
.
Determining a System's Current Run Level
To determine a system's
current run level, use the who -r command.
Example 4-11 Determining a System's Run Level
The output of the who –r command
displays information about a system's current run level, as well as previous
run levels.
$ who -r
. run-level 3 Dec 13 10:10 3 0 S
$
| |
run-level 3
| Identifies the current run level
|
Dec 13 10:10
| Identifies the date of last run level change
|
3
| Also identifies the current run level
|
0
| Identifies the number of times the system has been at this run level
since the last reboot
|
S
| Identifies the previous run level
|
|