• Aucun résultat trouvé

Changing System Run Levels

A run-level is a system state in which valid users can run a specific set of processes. Most of the time, the system functions in run-level 2, the initdefault run-level that lets users log in and use system resources. On occasion, you change to run-level s, a special administrative or single-user state used for system administration tasks.

Prerequisites and Conditions

• Only the system administrator should change the run-level. Do not leave the system console unattended in this regard.

• Anyone who has write permission to / etc/ini ttab can create a new

run-level or redefine the existing run-levels. In a listing of / etc/ini ttab, the permissions should look like this:

-rw-r--r-- 1 root root date information /etc/inittab If the file does not have these permissions, execute:

chmod 644 /etc/inittab

• The System Administration Concepts manual has detailed information about run-levels. Here is a brief look at them:

o

A special run-level used for installation. Do not use this run-level.

1 A single-user mode used during installation and maintenance.

The system may reboot in single-user mode during some system administration tasks.

s or S A special single-user (administrative) mode used for checking the file system or performing system backups. At run-level s, the root user can access the system from the system console. The only processes that can run on the system are the shell and the processes the root user invokes. Run level s is not recommended for routine use because processes that monitor the system do not execute.

4-10 Starting and Stopping HP-UX

2 A multi-user run-level that constitutes the system's normal operating state (the default run-level when the system starts up).

3 to 6 One can define (use) these run-levels for specific applications or commands. For example, the X Environment program uses run-level 3. By using this run-level, you get special login features within an Xll window. You can use the traditional login program by changing the system to run-level 2.

• Some system administration tasks require being in the single-user run-level (for example, performing a file system consistency check). In general, anytime you perform a major operation on a file system, rebuild the kernel, or otherwise make a significant change in HP -UX, determine if you need to be in the single-user run-level to perform the task. This manual tries to indicate each task that must be performed in this run-level. But it is possible to perform an undescribed task and need to be in this run-level.

• If you change to a different run-level, the processes corresponding to entries in / etc/ini ttab that do not accommodate the new run-level terminate. For example, if you have not added a respawn getty entry for run-level 3 for the console, entering run-level 3 from run-level 2 causes the console to die.

• Each terminal or RS- 232 port used as an incoming terminal device must have a getty process executing. That is, for each incoming port, / etc/ini ttab must have a getty entry. For example, to accommodate a 3rd terminal in run-levels 2, 3, and 6 at 9600 baud, you could enter a line like this:

03:236:respawn:/etc/getty tty03 9600

See getty(lM) in the HP- UX Reference manual for more information.

Starting and Stopping HP-UX 4-11

Procedures for Changing the Run Level

Changing to the Single-user Run Level

1. Tell users you are about to shut down the system. Have them save their work and then log off. Indicate you will provide a graceperiod of 30 seconds (for example) for them to log off when the shutdown process begins.

2. From the system console, log in as root and execute:

shutdown 30

The / etc/ shutdown command terminates all processes except those that can run in the single-user state. During the shutdown process, the system warns users that they have a certain period to log off before the system stops. Not specifying a graceperiod gives users 60 seconds to log off.

3. When the shutdown process completes, use ps -ef to see which processes are still running. Any user-related process should not still be alive.

Changing to Run Level 2

When you change the system to a different run-level, you will probably want to return to run-level 2, the multi-user run-level.

1. Warn any users who may be logged in that you intend to change the

run-level. Changing to another run-level while users are logged can kill their processes. You can do this verbally or use the / etc/wall (or / etc/ cwall commands to broadcast a message that appears on the screens of all active users. See the chapter named "Constructing an HP-UX System" for information about these commands.

2. Become the root user.

3. Execute:

in it 2

4. Wait for the system to change to the new run-level.

4-12 Starting and Stopping HP-UX

Changing to a Numbered Run Level To change to a numbered run-level:

1. Warn any users who may be logged in that you intend to change the

run-level. Changing to another run-level while users are logged can kill their processes. You can do this verbally or use the / etc/wall (or / etc/ cwall commands to broadcast a message that appears on the screens of all active users. See the chapter named "Constructing an HP-UX System" for information about these commands.

2. Log in as root.

3. After users log off the system, force the system to write the contents of its 110 buffers to disk by executing:

sync sync

The two sync commands ensure that all data is written to the buffers.

4. Use /etc/init to change the run-level (for example level 3):

/etc/init 3

Starting and Stopping HP-UX 4-13