<<

Rebooting & Shutting Down

The system buffers changes in memory and writes them back to disk only sporadically. This scheme makes disk I/O faster, but it also makes the file system susceptible to data loss when the system is rudely halted. Traditional UNIX machines were very touchy about how they were shut down. Recent systems have become less sensitive, but it is always a good idea to shut down the machine nicely.

On non-UNIX operating systems, rebooting the is an appropriate first course of treatment for almost any problem. On a UNIX system, it is better to think first and reboot second. UNIX problems tend to be subtler and more complex so blindly rebooting is effective in a much smaller percentage of cases. UNIX systems also take a long to boot, and multiple users may be inconvenienced.

Unlike bootstrapping, which can be done in essentially only one ways, there are a number of ways to shut down or reboot a UNIX system. They are:

Turning off the power

Using the command

Using the halt and reboot commands

Sending a TERM

Using telinit to change init’s run level

Killing init

Turning off the Power

Even on small UNIX systems, turning off the power is not a good way to shut down a system. You can potentially lose data and leave the system’s files in an inconsistent state.

shutdown shutdown is the safest, most considerate, and most thorough way to initiate a halt, reboot, or to return to single user mode. You can ask shutdown to a while before bringing down the system. During the waiting period, shutdown sends a message via to all logged-in users progressively shorter intervals, warning them of the impending downtime. By default, the warnings simply say that the system is being shut down and gives the time remaining until the machine is halted. On most systems, users cannot log in when a shutdown is imminent.

On Solaris systems use the command

# /usr/sbin/shutdown –g -i<6|0|S> where is the number of seconds before the system is halted, run level 6 is a reboot, run level 0 is a halt and run level S is halt multiuser mode and enter single user mode.

halt

The halt command performs the essential duties required to bring the system down. It is called by shutdown –i0, but it can also be used by itself. halt logs the shutdown, kills nonessential processes, executes the sync system call, waits for the file system writes to complete, and then halts the kernel.

reboot reboot is almost identical to halt, but it causes the machine to reboot from scratch rather than halting. reboot is called by shutdown –i6.

Killing init init is so important to the operation of the system, that if it is killed with –KILL or kill -9, most computers will reboot automatically, some kernels just panic.