[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: "shutdown -r" instead of "reboot"? (was Re: ack! I've hosed init



In article <cistron.199812082355.AAA30080@Server.RZ.RWTH-Aachen.DE>,
Ralf G. R. Bergs <rabe@RWTH-Aachen.DE> wrote:
>On Wed, 09 Dec 1998 00:33:53 +0100, Miquel van Smoorenburg wrote:
>
>>Besides, it is good practice to use "shutdown -r now" instead
>>of reboot. Or just press ctrlaltdel, because then init just calls
>>the command "shutdown -r now" for you.
>
>Could you please explain why?

"reboot" under SystemV traditionally does just that, it reboots the
system. Hard.

Due to historical BSD tradition and the first init for Linux being BSD-like
(remember simpleinit?) people expect "reboot" to do an orderly shutdown
and reboot.

So, the "reboot" command has to guess the context in which it is being
used, and then decide to do a hard reboot by calling the reboot(2)
system call, or to do an orderly shutdown. In the last case, it just
calls "shutdown -r now" for you!

It guesses that context by checking the runlevel (which is stored in
/var/run/utmp on a correctly running system). If it's "0" or "6",
reboot will assume it has to do a hard reboot. If it's "1" ... "5",
shutdown will be called. If it's anything else or reboot gets confused,
it prints a warning messages and calls shutdown.

Mike.
-- 
Indifference will certainly be the downfall of mankind, but who cares?


Reply to: