Reputation: 181
What is the real difference between the LINUX_REBOOT_CMD_HALT
and LINUX_REBOOT_CMD_POWER_OFF
arguments to the reboot()
system call (resp. the RB_HALT_SYSTEM
and RB_POWER_OFF
arguments given to its wrapper function)?
The reboot(2)
manual page has the following descriptions (differences emphasized):
RB_HALT_SYSTEM
LINUX_REBOOT_CMD_HALT
(
RB_HALT_SYSTEM
,0xcdef0123
; since Linux 1.1.76). The message "System halted." is printed, and the system is halted. Control is given to the ROM monitor, if there is one. If not preceded by async(2)
, data will be lost.
LINUX_REBOOT_CMD_POWER_OFF
(
RB_POWER_OFF
,0x4321fedc
; since Linux 2.1.30). The message "Power down." is printed, the system is stopped, and all power is removed from the system, if possible. If not preceded by async(2)
, data will be lost.
Reading the descriptions, a few questions come up:
What is the difference between halted and stopped?
Would a reboot(RB_HALT_SYSTEM)
call not remove power from the
system?
Where would the "System halted." and "Power down." messages be printed?
Upvotes: 1
Views: 1219
Reputation: 365237
I don't think there is a difference; those words are synonyms in common English and I think this documentation is just using their English meaning, not as specific technical terms.
correct, that's exactly what the docs are trying to tell you.
You can easily try these for yourself to see what they do; the user-space shutdown(8)
command has -H
(halt) and -P
/ -h
(poweroff) options, as well as -r
. Read the man page. I assume it eventually makes a reboot(2)
system call, or causes init
to make one, after a sync
.
And yes, the traditional shutdown -h
command is halt + power off, i.e. POWER_OFF
. Back in the old days, computers didn't used to be able to power themselves off, but these days that's usually what people think of as a non-reboot shutdown. Especially on systems where the kernel can't "return" to a BIOS / firmware command interface.
On a PC, one of the few use-cases I could imagine for halt without poweroff would be to insert a USB drive or CD before pressing the reset button (or ctrl+alt+delete). But maybe you don't want the currently-booted Linux kernel to react to the new hardware at all, so you want to halt Linux first.
You could poweroff to do this, but you don't need to and there's no need to start/stop your rotating disks and put extra wear on their motors.
Upvotes: 1