Contained Within
Find More Documentation
Featured Support Resources
| PDF로 이 문서 다운로드
Halting a System
2
- This chapter has the following sections:
-
- The SunOS system software is designed to be left running continuously so that the electronic mail and network software can work correctly. You must, however, halt or shut down a system when:
-
- Turning off system power
- Installing a new release of the operating system
- Anticipating a power outage
- Adding hardware to the system
- Performing maintenance on a file system
- This chapter describes system init states (also called run levels) and procedures for shutting down systems. Procedures for booting a system are discussed in the Administration Supplement for Solaris Platforms. Boot files are described in Chapter 3, "Boot Files."
Init States
- The init state in which the system is running defines what services and resources are available to users. A system can run in only one init state at a time.
- The SunOS system software has eight init states, shown in Table 2-1. The default init state, specified in the /etc/inittab file, runs at level 3 for SunOS system software.
-
Table 2-1
| Init State/Run Level | Function |
| 0 | Power-down state |
| 1 | System administrator state (single-user) |
| 2 | Multiuser state (resources not exported) |
| 3 | Multiuser state (resources exported) |
| 4 | Alternative multiuser state (currently unused) |
| 5 | Software reboot state |
| 6 | Reboot |
| S,s | Single-user state |
- The /sbin/init program keeps the system running correctly. In addition, /sbin/init is the command you use to change init states. You can also specify the init state as an argument to the shutdown command with the -i option.
- There are four types of init states:
-
- Power-down (run level 0)
- Single-user (run levels 1 and s or S)
- Multiuser (run levels 2 and 3)
- Reboot (run levels 5 and 6)
- When preparing to do a system administration task, you need to determine which init state is appropriate for the system and the task at hand.
-
Table 2-2 describes the use of each init state.
-
Table 2-2
| Init State | Run Level | Use This Level... |
| power-down state | 0 | To shut down the system so that it is safe to turn off the power. |
| system administrator state | 1 | When performing administrative tasks that require you to be the only user on the system. / and /usr are the only file systems mounted, and you can access only minimum kernel utilities. The terminal from which you issue this command becomes the console. No other users are logged in. |
| multiuser state | 2 | For normal operations. Multiple users can access the system and the entire file system. All daemons are running except for NFS server and syslog. |
| remote resource-sharing state | 3 | For normal operations with NFS resource-sharing available. |
| alternative multiuser state | 4 | This level is currently unavailable. |
| interactive reboot state | 5 | When you want to be prompted for a device other than the default boot devices. You can also change to this level by using the reboot -a command. |
| reboot state | 6 | To shut down the system to run level 0, and then reboot to multiuser level (or whatever level is the default in the inittab file). |
| single-user state | s or S | To run as a single user with all file systems mounted and accessible. |
· How to Determine a System's Init State
-
* Type who -r and press Return. The run level, date and time, process termination status, process ID, and process exit status are displayed.
- In this example, pluto is at the default multiuser init state (run level 3), the date and time are 3 Feb 6 15:46, the process termination status is 3, the process ID is 0, and process exit status is S:
-
pluto% who -r
. run-level 3 Feb 6 15:46 3 0 S
pluto%
|
· How to Change the Init State
-
-
Become superuser.
-
Type init n and press Return.
- To shut down the system:
-
saturn% su
Password:
# init 0
|
- To change to single-user state:
-
saturn% su
Password:
# init 1
|
- To change to multiuser state, with no NFS server daemons running:
-
saturn% su
Password:
# init 2
|
- To change to multiuser state, with NFS server daemons running:
-
saturn% su
Password:
# init 3
|
- To shut down and reboot a system:
-
saturn% su
Password:
# init 6
|
Choosing Which Shutdown Command to Use
- When preparing to shut down a system, you need to determine which of the following commands is appropriate for the system and the task at hand:
-
-
/usr/sbin/shutdown
-
/sbin/init
-
/usr/sbin/halt
-
/usr/sbin/reboot
- These commands initiate shutdown procedures, kill all running processes, write data to disk, and shut down the system software to the appropriate run level.
-
Table 2-3 describes each of the shutdown commands. The following sections describe how you might use each of the shutdown commands:
-
Table 2-3
| Command | Purpose |
| shutdown | Use the shutdown command when shutting down a system with multiple users. The shutdown command sends a warning message to all users who are logged in, waits for 60 seconds (the default), and then shuts down the system to single-user state. You can choose a different default wait time (see "How to Change the Shutdown Grace Period" on page 25). |
| init | Use the init command to shut down a single-user system or to change its run level. You can use init to place the system in power-down state (init 0) or into single-user state (init 1). |
| halt | Use the halt command when the system must be stopped immediately and it is acceptable not to warn any current users. The halt command shuts down the system without any delay. It does not warn any other users on the system. |
| reboot | Use the reboot command to shut down a single-user system and bring it into multiuser state. reboot does not warn other users on the system. |
-
Note - init and shutdown are the most reliable ways to shut down a system because they use rc scripts to kill running processes and shut down the system with minimal data loss. The halt and reboot commands do not run the rc scripts properly and are not the preferred method for shutting down the system. See Chapter 3, "Boot Files," for more information about the rc scripts.
Shutting Down a System by Using shutdown
- This section provides examples of how to use the shutdown command to shut down a system.
· How to Shut Down a Multiuser System
- Before shutting down a multiuser system, notify users and give them time to complete critical procedures.
-
-
Type who and press Return.
A list of all logged-in users is displayed. You may want to send mail or broadcast a message to let users know that the system is being shut down.
-
Become superuser.
-
Type cd / and press Return.
You must be in the root directory to run the shutdown command.
-
Type shutdown and press Return.
A message is broadcast to all users. After a 60-second wait, you are asked to confirm that you want to shut down the system.
-
Type y and press Return.
The system is shut down to single-user state and you are prompted for the root password.
-
Type the root password.
The system is in single-user state and you can perform maintenance tasks.
-
Press Control-d to return to the default run system level.
The following example shows the messages that may result when you use the shutdown command.
-
# cd /
# shutdown
Shutdown started Fri Jan 14 10:50:35 EDT 1994
Broadcast message from root (console) on earth Fri Aug 9 10:59:35.
THE SYSTEM IS BEING SHUT DOWN NOW ! ! !
LOG OFF NOW OR RISK YOUR FILES BEING DAMAGED
Do you want to continue? (y or n): y
|
-
The system is down.
Changing to init state s - please wait.
INIT: New run level S
INIT: SINGLE USER MODE
Type Ctrl-d to proceed with normal startup,
(or give root password for system maintenance):
|
· How to Shut Down and Reboot a Multiuser System
-
-
Become superuser.
-
Type cd / and press Return.
You must be in the root directory to run the shutdown command.
-
Type shutdown -i6 and press Return.
A message is broadcast to all users. Then the rc6 script is executed, the system is shut down to power-down state, and you can then bring it back up to multiuser state.
Overriding the shutdown Defaults
- The following examples show how to change the default actions of the shutdown command.
· How to Shut Down a System Without Confirmation
-
-
Become superuser.
-
Type cd / and press Return.
You must be in the root directory to run the shutdown command.
-
Type shutdown -y and press Return.
The shutdown proceeds without asking you to type y to confirm it.
· How to Change the Shutdown Grace Period
-
-
Become superuser.
-
Type cd / and press Return.
You must be in the root directory to run the shutdown command.
-
Type shutdown -gnnn and press Return.
The grace period is changed to the number of seconds you specify.
- This example changes the grace period to 120 seconds.
-
Shutting Down a System by Using init
· How to Shut Down a Single-User System
-
* Type init 0 and press Return. The init command runs scripts that bring the system down cleanly. No warning messages are broadcast.
· How to Shut Down and Reboot a Single-User System
-
* Type init 6 and press Return. This command writes data to the disk, kills all active processes, brings the system down to power-down state, and displays the PROM prompt. You can then reboot the system to the default level (usually multiuser).
· How to Shut Down Your System Quickly
- To shut down a system quickly:
-
* Type uadmin 2 0 and press Return. Data is written to the disk and the system is brought to power-down state. The system displays the PROM prompt.
|
|