Debian 9 halt does not really power off in new versions - why?2019 Community Moderator ElectionWhat is the difference between Halt and Shutdown commands?DPMS does not work: the monitor is not switched offConsole won't power off on PowerPC with Debianwhy debian repository does not contain lokkit?Why is Debian updating old package versions instead of offering new versions? (openssl)Why does the same Debian release have different kernel versions?Resuming Linux from hibernate on ThinkPad X220 fails with black screen or rebootDoes Debian 9 (Stretch) have a new updating mechanism?ACPI kernel parameter options for HP ProLiant DL380 G5How to power off normally after Debian crashed?Debian stretch does not boot
Would this string work as string?
Asserting that Atheism and Theism are both faith based positions
Help with identifying unique aircraft over NE Pennsylvania
How much propellant is used up until liftoff?
Why is "la Gestapo" feminine?
Knife as defense against stray dogs
Why doesn't the fusion process of the sun speed up?
If I cast enlarge/reduce on an arrow, what weapon could it count as?
Air travel with refrigerated insulin
Did Nintendo change its mind about 68000 SNES?
Writing in a Christian voice
Why is participating in the European Parliamentary elections used as a threat?
Print last inputted byte
Hackerrank All Women's Codesprint 2019: Name the Product
Print a physical multiplication table
How can I create URL shortcuts/redirects for task/diff IDs in Phabricator?
Does convergence of polynomials imply that of its coefficients?
TDE Master Key Rotation
pipe commands inside find -exec?
What is the reasoning behind standardization (dividing by standard deviation)?
What (if any) is the reason to buy in small local stores?
Friend wants my recommendation but I don't want to
Don't understand why (5 | -2) > 0 is False where (5 or -2) > 0 is True
Splitting fasta file into smaller files based on header pattern
Debian 9 halt does not really power off in new versions - why?
2019 Community Moderator ElectionWhat is the difference between Halt and Shutdown commands?DPMS does not work: the monitor is not switched offConsole won't power off on PowerPC with Debianwhy debian repository does not contain lokkit?Why is Debian updating old package versions instead of offering new versions? (openssl)Why does the same Debian release have different kernel versions?Resuming Linux from hibernate on ThinkPad X220 fails with black screen or rebootDoes Debian 9 (Stretch) have a new updating mechanism?ACPI kernel parameter options for HP ProLiant DL380 G5How to power off normally after Debian crashed?Debian stretch does not boot
IMPORTANT:
I am able to restore halt old behavior if I do:
apt install sysvinit-core
Plus: Old RedHat based versions are able to power off with halt too.
I am trying to understand why in Debian 9 you should not use halt to turn off your computer anymore. That behavior are removed from systemd. I am a bit scary, but I think there must be a good logical reason.
Are other unixes or unix-like with this same behavior or are Linux turning into something different?
Now if you want to turn off the machine after the system shutdown you should use poweroff instead of halt...
Somebody know how this command are interpreted in other Unix-Like?
That is not a duplicated, because, debian 7 can power off with halt for example.
debian halt
|
show 4 more comments
IMPORTANT:
I am able to restore halt old behavior if I do:
apt install sysvinit-core
Plus: Old RedHat based versions are able to power off with halt too.
I am trying to understand why in Debian 9 you should not use halt to turn off your computer anymore. That behavior are removed from systemd. I am a bit scary, but I think there must be a good logical reason.
Are other unixes or unix-like with this same behavior or are Linux turning into something different?
Now if you want to turn off the machine after the system shutdown you should use poweroff instead of halt...
Somebody know how this command are interpreted in other Unix-Like?
That is not a duplicated, because, debian 7 can power off with halt for example.
debian halt
Plainhaltpowers off a macOS system, but not an OpenBSD system.haltis not a POSIX utility, nor ispowerofforshutdownor any similar utility.
– Kusalananda
Mar 14 at 18:30
Not duplicated, because halt can power off Debian 8 for example. I just dont understand why removing that behavior!
– Luciano Andress Martini
Mar 14 at 18:41
1
@DopeGhoti I don't think this is a dupe. The OP wants to know why this change happened, not what the difference betweenhaltandshutdownmay be.
– terdon♦
Mar 14 at 19:10
1
Yes, exactly, I am trying to understand why this change happened. Thank you.
– Luciano Andress Martini
Mar 14 at 19:35
1
haltallows for the system to be halted with diagnostic kernel messages still visible on the console on some systems; this is the reason for a distinction betweenhaltandpoweroffto exist at all.
– DopeGhoti
Mar 14 at 21:42
|
show 4 more comments
IMPORTANT:
I am able to restore halt old behavior if I do:
apt install sysvinit-core
Plus: Old RedHat based versions are able to power off with halt too.
I am trying to understand why in Debian 9 you should not use halt to turn off your computer anymore. That behavior are removed from systemd. I am a bit scary, but I think there must be a good logical reason.
Are other unixes or unix-like with this same behavior or are Linux turning into something different?
Now if you want to turn off the machine after the system shutdown you should use poweroff instead of halt...
Somebody know how this command are interpreted in other Unix-Like?
That is not a duplicated, because, debian 7 can power off with halt for example.
debian halt
IMPORTANT:
I am able to restore halt old behavior if I do:
apt install sysvinit-core
Plus: Old RedHat based versions are able to power off with halt too.
I am trying to understand why in Debian 9 you should not use halt to turn off your computer anymore. That behavior are removed from systemd. I am a bit scary, but I think there must be a good logical reason.
Are other unixes or unix-like with this same behavior or are Linux turning into something different?
Now if you want to turn off the machine after the system shutdown you should use poweroff instead of halt...
Somebody know how this command are interpreted in other Unix-Like?
That is not a duplicated, because, debian 7 can power off with halt for example.
debian halt
debian halt
edited 5 hours ago
Luciano Andress Martini
asked Mar 14 at 18:25
Luciano Andress MartiniLuciano Andress Martini
4,0031136
4,0031136
Plainhaltpowers off a macOS system, but not an OpenBSD system.haltis not a POSIX utility, nor ispowerofforshutdownor any similar utility.
– Kusalananda
Mar 14 at 18:30
Not duplicated, because halt can power off Debian 8 for example. I just dont understand why removing that behavior!
– Luciano Andress Martini
Mar 14 at 18:41
1
@DopeGhoti I don't think this is a dupe. The OP wants to know why this change happened, not what the difference betweenhaltandshutdownmay be.
– terdon♦
Mar 14 at 19:10
1
Yes, exactly, I am trying to understand why this change happened. Thank you.
– Luciano Andress Martini
Mar 14 at 19:35
1
haltallows for the system to be halted with diagnostic kernel messages still visible on the console on some systems; this is the reason for a distinction betweenhaltandpoweroffto exist at all.
– DopeGhoti
Mar 14 at 21:42
|
show 4 more comments
Plainhaltpowers off a macOS system, but not an OpenBSD system.haltis not a POSIX utility, nor ispowerofforshutdownor any similar utility.
– Kusalananda
Mar 14 at 18:30
Not duplicated, because halt can power off Debian 8 for example. I just dont understand why removing that behavior!
– Luciano Andress Martini
Mar 14 at 18:41
1
@DopeGhoti I don't think this is a dupe. The OP wants to know why this change happened, not what the difference betweenhaltandshutdownmay be.
– terdon♦
Mar 14 at 19:10
1
Yes, exactly, I am trying to understand why this change happened. Thank you.
– Luciano Andress Martini
Mar 14 at 19:35
1
haltallows for the system to be halted with diagnostic kernel messages still visible on the console on some systems; this is the reason for a distinction betweenhaltandpoweroffto exist at all.
– DopeGhoti
Mar 14 at 21:42
Plain
halt powers off a macOS system, but not an OpenBSD system. halt is not a POSIX utility, nor is poweroff or shutdown or any similar utility.– Kusalananda
Mar 14 at 18:30
Plain
halt powers off a macOS system, but not an OpenBSD system. halt is not a POSIX utility, nor is poweroff or shutdown or any similar utility.– Kusalananda
Mar 14 at 18:30
Not duplicated, because halt can power off Debian 8 for example. I just dont understand why removing that behavior!
– Luciano Andress Martini
Mar 14 at 18:41
Not duplicated, because halt can power off Debian 8 for example. I just dont understand why removing that behavior!
– Luciano Andress Martini
Mar 14 at 18:41
1
1
@DopeGhoti I don't think this is a dupe. The OP wants to know why this change happened, not what the difference between
halt and shutdown may be.– terdon♦
Mar 14 at 19:10
@DopeGhoti I don't think this is a dupe. The OP wants to know why this change happened, not what the difference between
halt and shutdown may be.– terdon♦
Mar 14 at 19:10
1
1
Yes, exactly, I am trying to understand why this change happened. Thank you.
– Luciano Andress Martini
Mar 14 at 19:35
Yes, exactly, I am trying to understand why this change happened. Thank you.
– Luciano Andress Martini
Mar 14 at 19:35
1
1
halt allows for the system to be halted with diagnostic kernel messages still visible on the console on some systems; this is the reason for a distinction between halt and poweroff to exist at all.– DopeGhoti
Mar 14 at 21:42
halt allows for the system to be halted with diagnostic kernel messages still visible on the console on some systems; this is the reason for a distinction between halt and poweroff to exist at all.– DopeGhoti
Mar 14 at 21:42
|
show 4 more comments
2 Answers
2
active
oldest
votes
Debian
When using SysVinit in Debian(esque) systems, /etc/defaults/halt includes a variable that defines whether the system will run halt or poweroff at the end of transition to runlevel 0. The default setting is HALT=poweroff.
Before SysVinit 2.74 you were not supposed to run halt directly, and starting from that version, the SysVinit halt command will just call shutdown -h unless the current runlevel is 0 or 6. This is documented in halt(8) man page. At the end of transition to runlevel 0 the runlevel scripts will run $HALT, which is equal to poweroff by default.
RHEL/CentOS
RHEL/CentOS 5 was the last version to use SysVinit: version 6 used upstart and version 7 uses systemd. In RHEL 5.11, the last script to run when transitioning to runlevel 0 is /etc/init.d/halt, and its last lines are:
[ "$INIT_HALT" != "HALT" ] && HALTARGS="$HALTARGS -p"
exec $command $HALTARGS
Since the same script is also run at the end of transition to runlevel 6 (reboot), the actual command to run is defined by the variable $command, and it will be either /sbin/halt or /sbin/reboot. According to the value of the $INIT_HALT variable, the script will decide whether or not add the -p option. That variable is set by /sbin/shutdown. The RHEL 5.11 shutdown(8) man page says:
HALT OR POWEROFF
The -H option just sets the init environment variable INIT_HALT to HALT, and the -P option just sets that variable to POWEROFF. The shutdown script that calls halt(8) as the last thing in the shutdown sequence should check these environment variables and call halt(8) with the right options for these options to actually have any effect.
Debian 3.1 (sarge) supports this.
(Yes, the RHEL 5.11 man page mentions Debian 3.1! I guess someone at RedHat porting patches from various sources to RHEL missed one reference...)
It looks like RedHat has decided to code the above-mentioned test in the /etc/init.d/halt script in such a way that switching off the power (using /sbin/halt -p at the end of shutdown) is the default halt action: the only way to achieve halt without poweroff is to use the upper-case -H option of the shutdown command to explicitly request it, e.g. shutdown -hH now
But again, the default powerdown is triggered by the runlevel scripts customized by the Linux distribution, so it's not really a feature of the SysVinit halt command.
Historical note
Old SysVinit-using systems (both Linux and non) used to have several commands that were not intended to be used directly, but only as part of the appropriate shutdown/reboot scripts. Before SysVinit 2.74, the /sbin/halt command with no options would have done the same as halt -f of modern SysVinit does, i.e. a brutal, immediate kernel shutdown without stopping any services or unmounting filesystems.
For the same reason, being used to the Linux killall command can be dangerous on other Unixes. Its man page even has this ominous warning:
Be warned that typing killall name may not have the desired effect on non-Linux systems, especially when done by a privileged user.
This is because the classic SystemV killall was one of those commands designed to be used only as part of a shutdown script. In Linux distributions with SysVinit, the classic version of the command may be found as killall5. It literally kills all processes except kernel threads and processes in its own session: its intended use is in a shutdown script after shutting down all services, just before unmounting the local filesystems, to kill of any other processes that might delay or prevent the unmounting.
(How I know this, you ask? Well, I once made the mistake of running killall <something> as root on a Solaris 2.6 system. A very effective learning experience.)
Yes that is what I am expecting! Very nice informations! Thank you a lot, specially about the notes about Red Hat doing the same behavior in older versions!
– Luciano Andress Martini
5 hours ago
add a comment |
This question is predicated upon multiple falsehoods.
One did not use halt to turn off one's computer, and this has not changed with systemd.
halt a.k.a. haltsys shuts down and halts. poweroff is a newer command that shuts down and powers off. (https://unix.stackexchange.com/a/196471/5132 explains the subtleties of this which I am going to gloss over here, since the question is only about Linux operating systems. This answer focuses on just the AT&T System 5 UNIX side of the universe.)
As I explained at https://superuser.com/a/900205/38062, computers are not necessarily able to power off under software control. The action of the haltsys and halt command has conventionally been to shutdown and halt the machine, the next action being the operator using a physical reset button or power switch.
halt gained a -p/--poweroff option to make it equivalent to poweroff, but this is symptomatic of a general growth of overlapping and self-contradictory options to these commands. Witness the manual page for the Upstart halt command in Debian 7. There's halt --poweroff there. The manual page for the van Smoorenburg halt command in Debian 7 similarly has halt -p.
But this is not something that has changed with systemd. systemd provides the same. The systemd halt command also has --poweroff. It furthermore has --reboot and (for good measure) --halt options.
I had to do the same with the halt/haltsys command in the nosh toolset, for compatibility.
You may erroneously think that plain old halt powered off your computer. But that was unequivocally wrong for Upstart, and only true for the van Smoorenburg toolset if you happened to hit a bug.
The bug, which has only this year finally been fixed, was that the van Smoorenburg halt command would simply ignore the presence or absence of the -p option and instead decide whether to halt or power off according to the value of a setting in /etc/default/halt. If you happened to have that setting set to power off, then halt would always power off, even if no -p option were supplied. Conversely, if you happened to have that setting set to halt, then halt would always halt, even if a -p option were supplied.
But this was a bug, not the documented nor intended behaviour, not the behaviour of every halt command that was available on Debian, and not the conventional behaviour of the halt command in general.
Further reading
- Jonathan de Boyne Pollard (2018-12-07). Bug#586709: closed by Thomas Goirand. Debian bug #586709.
- Jessie Smith (2019-03-08). initscripts: command
haltunintended changed behaviour. Debian bug #743555.
A falsehood that running apt install sysvinit-core turned true! Why? I just installed sysvinit, and at end halt says "Will now halt" exactly in that moment the machine powered off, how could this be a falsehood, it looks like the developer of sysvinit still has this falsehood! and plus that halt -f turns off the machine immediately.
– Luciano Andress Martini
11 hours ago
1
When using SysVinit in Debian(esque) systems,/etc/defaults/haltincludes a variable that defines whether the system will runhaltorpoweroffat the end of transition to runlevel 0. The default setting isHALT=poweroff. Before SysVinit 2.74 you were not supposed to runhaltdirectly, and starting from that version, the SysVinithaltcommand will just callshutdown -hunless the current runlevel is 0 or 6. This is documented inhalt(8)man page. At the end of transition to runlevel 0 the runlevel scripts will run$HALT, which is equal topoweroffby default.
– telcoM
10 hours ago
1
@telcoM Thank you very much for this! That is enough for me, if you put that as a answer I will mark it as the correct answer. (Note one thing (not very important), CentOS seems to have the same behavior in my old servers). Can you post this as a answer please?
– Luciano Andress Martini
8 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f506341%2fdebian-9-halt-does-not-really-power-off-in-new-versions-why%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Debian
When using SysVinit in Debian(esque) systems, /etc/defaults/halt includes a variable that defines whether the system will run halt or poweroff at the end of transition to runlevel 0. The default setting is HALT=poweroff.
Before SysVinit 2.74 you were not supposed to run halt directly, and starting from that version, the SysVinit halt command will just call shutdown -h unless the current runlevel is 0 or 6. This is documented in halt(8) man page. At the end of transition to runlevel 0 the runlevel scripts will run $HALT, which is equal to poweroff by default.
RHEL/CentOS
RHEL/CentOS 5 was the last version to use SysVinit: version 6 used upstart and version 7 uses systemd. In RHEL 5.11, the last script to run when transitioning to runlevel 0 is /etc/init.d/halt, and its last lines are:
[ "$INIT_HALT" != "HALT" ] && HALTARGS="$HALTARGS -p"
exec $command $HALTARGS
Since the same script is also run at the end of transition to runlevel 6 (reboot), the actual command to run is defined by the variable $command, and it will be either /sbin/halt or /sbin/reboot. According to the value of the $INIT_HALT variable, the script will decide whether or not add the -p option. That variable is set by /sbin/shutdown. The RHEL 5.11 shutdown(8) man page says:
HALT OR POWEROFF
The -H option just sets the init environment variable INIT_HALT to HALT, and the -P option just sets that variable to POWEROFF. The shutdown script that calls halt(8) as the last thing in the shutdown sequence should check these environment variables and call halt(8) with the right options for these options to actually have any effect.
Debian 3.1 (sarge) supports this.
(Yes, the RHEL 5.11 man page mentions Debian 3.1! I guess someone at RedHat porting patches from various sources to RHEL missed one reference...)
It looks like RedHat has decided to code the above-mentioned test in the /etc/init.d/halt script in such a way that switching off the power (using /sbin/halt -p at the end of shutdown) is the default halt action: the only way to achieve halt without poweroff is to use the upper-case -H option of the shutdown command to explicitly request it, e.g. shutdown -hH now
But again, the default powerdown is triggered by the runlevel scripts customized by the Linux distribution, so it's not really a feature of the SysVinit halt command.
Historical note
Old SysVinit-using systems (both Linux and non) used to have several commands that were not intended to be used directly, but only as part of the appropriate shutdown/reboot scripts. Before SysVinit 2.74, the /sbin/halt command with no options would have done the same as halt -f of modern SysVinit does, i.e. a brutal, immediate kernel shutdown without stopping any services or unmounting filesystems.
For the same reason, being used to the Linux killall command can be dangerous on other Unixes. Its man page even has this ominous warning:
Be warned that typing killall name may not have the desired effect on non-Linux systems, especially when done by a privileged user.
This is because the classic SystemV killall was one of those commands designed to be used only as part of a shutdown script. In Linux distributions with SysVinit, the classic version of the command may be found as killall5. It literally kills all processes except kernel threads and processes in its own session: its intended use is in a shutdown script after shutting down all services, just before unmounting the local filesystems, to kill of any other processes that might delay or prevent the unmounting.
(How I know this, you ask? Well, I once made the mistake of running killall <something> as root on a Solaris 2.6 system. A very effective learning experience.)
Yes that is what I am expecting! Very nice informations! Thank you a lot, specially about the notes about Red Hat doing the same behavior in older versions!
– Luciano Andress Martini
5 hours ago
add a comment |
Debian
When using SysVinit in Debian(esque) systems, /etc/defaults/halt includes a variable that defines whether the system will run halt or poweroff at the end of transition to runlevel 0. The default setting is HALT=poweroff.
Before SysVinit 2.74 you were not supposed to run halt directly, and starting from that version, the SysVinit halt command will just call shutdown -h unless the current runlevel is 0 or 6. This is documented in halt(8) man page. At the end of transition to runlevel 0 the runlevel scripts will run $HALT, which is equal to poweroff by default.
RHEL/CentOS
RHEL/CentOS 5 was the last version to use SysVinit: version 6 used upstart and version 7 uses systemd. In RHEL 5.11, the last script to run when transitioning to runlevel 0 is /etc/init.d/halt, and its last lines are:
[ "$INIT_HALT" != "HALT" ] && HALTARGS="$HALTARGS -p"
exec $command $HALTARGS
Since the same script is also run at the end of transition to runlevel 6 (reboot), the actual command to run is defined by the variable $command, and it will be either /sbin/halt or /sbin/reboot. According to the value of the $INIT_HALT variable, the script will decide whether or not add the -p option. That variable is set by /sbin/shutdown. The RHEL 5.11 shutdown(8) man page says:
HALT OR POWEROFF
The -H option just sets the init environment variable INIT_HALT to HALT, and the -P option just sets that variable to POWEROFF. The shutdown script that calls halt(8) as the last thing in the shutdown sequence should check these environment variables and call halt(8) with the right options for these options to actually have any effect.
Debian 3.1 (sarge) supports this.
(Yes, the RHEL 5.11 man page mentions Debian 3.1! I guess someone at RedHat porting patches from various sources to RHEL missed one reference...)
It looks like RedHat has decided to code the above-mentioned test in the /etc/init.d/halt script in such a way that switching off the power (using /sbin/halt -p at the end of shutdown) is the default halt action: the only way to achieve halt without poweroff is to use the upper-case -H option of the shutdown command to explicitly request it, e.g. shutdown -hH now
But again, the default powerdown is triggered by the runlevel scripts customized by the Linux distribution, so it's not really a feature of the SysVinit halt command.
Historical note
Old SysVinit-using systems (both Linux and non) used to have several commands that were not intended to be used directly, but only as part of the appropriate shutdown/reboot scripts. Before SysVinit 2.74, the /sbin/halt command with no options would have done the same as halt -f of modern SysVinit does, i.e. a brutal, immediate kernel shutdown without stopping any services or unmounting filesystems.
For the same reason, being used to the Linux killall command can be dangerous on other Unixes. Its man page even has this ominous warning:
Be warned that typing killall name may not have the desired effect on non-Linux systems, especially when done by a privileged user.
This is because the classic SystemV killall was one of those commands designed to be used only as part of a shutdown script. In Linux distributions with SysVinit, the classic version of the command may be found as killall5. It literally kills all processes except kernel threads and processes in its own session: its intended use is in a shutdown script after shutting down all services, just before unmounting the local filesystems, to kill of any other processes that might delay or prevent the unmounting.
(How I know this, you ask? Well, I once made the mistake of running killall <something> as root on a Solaris 2.6 system. A very effective learning experience.)
Yes that is what I am expecting! Very nice informations! Thank you a lot, specially about the notes about Red Hat doing the same behavior in older versions!
– Luciano Andress Martini
5 hours ago
add a comment |
Debian
When using SysVinit in Debian(esque) systems, /etc/defaults/halt includes a variable that defines whether the system will run halt or poweroff at the end of transition to runlevel 0. The default setting is HALT=poweroff.
Before SysVinit 2.74 you were not supposed to run halt directly, and starting from that version, the SysVinit halt command will just call shutdown -h unless the current runlevel is 0 or 6. This is documented in halt(8) man page. At the end of transition to runlevel 0 the runlevel scripts will run $HALT, which is equal to poweroff by default.
RHEL/CentOS
RHEL/CentOS 5 was the last version to use SysVinit: version 6 used upstart and version 7 uses systemd. In RHEL 5.11, the last script to run when transitioning to runlevel 0 is /etc/init.d/halt, and its last lines are:
[ "$INIT_HALT" != "HALT" ] && HALTARGS="$HALTARGS -p"
exec $command $HALTARGS
Since the same script is also run at the end of transition to runlevel 6 (reboot), the actual command to run is defined by the variable $command, and it will be either /sbin/halt or /sbin/reboot. According to the value of the $INIT_HALT variable, the script will decide whether or not add the -p option. That variable is set by /sbin/shutdown. The RHEL 5.11 shutdown(8) man page says:
HALT OR POWEROFF
The -H option just sets the init environment variable INIT_HALT to HALT, and the -P option just sets that variable to POWEROFF. The shutdown script that calls halt(8) as the last thing in the shutdown sequence should check these environment variables and call halt(8) with the right options for these options to actually have any effect.
Debian 3.1 (sarge) supports this.
(Yes, the RHEL 5.11 man page mentions Debian 3.1! I guess someone at RedHat porting patches from various sources to RHEL missed one reference...)
It looks like RedHat has decided to code the above-mentioned test in the /etc/init.d/halt script in such a way that switching off the power (using /sbin/halt -p at the end of shutdown) is the default halt action: the only way to achieve halt without poweroff is to use the upper-case -H option of the shutdown command to explicitly request it, e.g. shutdown -hH now
But again, the default powerdown is triggered by the runlevel scripts customized by the Linux distribution, so it's not really a feature of the SysVinit halt command.
Historical note
Old SysVinit-using systems (both Linux and non) used to have several commands that were not intended to be used directly, but only as part of the appropriate shutdown/reboot scripts. Before SysVinit 2.74, the /sbin/halt command with no options would have done the same as halt -f of modern SysVinit does, i.e. a brutal, immediate kernel shutdown without stopping any services or unmounting filesystems.
For the same reason, being used to the Linux killall command can be dangerous on other Unixes. Its man page even has this ominous warning:
Be warned that typing killall name may not have the desired effect on non-Linux systems, especially when done by a privileged user.
This is because the classic SystemV killall was one of those commands designed to be used only as part of a shutdown script. In Linux distributions with SysVinit, the classic version of the command may be found as killall5. It literally kills all processes except kernel threads and processes in its own session: its intended use is in a shutdown script after shutting down all services, just before unmounting the local filesystems, to kill of any other processes that might delay or prevent the unmounting.
(How I know this, you ask? Well, I once made the mistake of running killall <something> as root on a Solaris 2.6 system. A very effective learning experience.)
Debian
When using SysVinit in Debian(esque) systems, /etc/defaults/halt includes a variable that defines whether the system will run halt or poweroff at the end of transition to runlevel 0. The default setting is HALT=poweroff.
Before SysVinit 2.74 you were not supposed to run halt directly, and starting from that version, the SysVinit halt command will just call shutdown -h unless the current runlevel is 0 or 6. This is documented in halt(8) man page. At the end of transition to runlevel 0 the runlevel scripts will run $HALT, which is equal to poweroff by default.
RHEL/CentOS
RHEL/CentOS 5 was the last version to use SysVinit: version 6 used upstart and version 7 uses systemd. In RHEL 5.11, the last script to run when transitioning to runlevel 0 is /etc/init.d/halt, and its last lines are:
[ "$INIT_HALT" != "HALT" ] && HALTARGS="$HALTARGS -p"
exec $command $HALTARGS
Since the same script is also run at the end of transition to runlevel 6 (reboot), the actual command to run is defined by the variable $command, and it will be either /sbin/halt or /sbin/reboot. According to the value of the $INIT_HALT variable, the script will decide whether or not add the -p option. That variable is set by /sbin/shutdown. The RHEL 5.11 shutdown(8) man page says:
HALT OR POWEROFF
The -H option just sets the init environment variable INIT_HALT to HALT, and the -P option just sets that variable to POWEROFF. The shutdown script that calls halt(8) as the last thing in the shutdown sequence should check these environment variables and call halt(8) with the right options for these options to actually have any effect.
Debian 3.1 (sarge) supports this.
(Yes, the RHEL 5.11 man page mentions Debian 3.1! I guess someone at RedHat porting patches from various sources to RHEL missed one reference...)
It looks like RedHat has decided to code the above-mentioned test in the /etc/init.d/halt script in such a way that switching off the power (using /sbin/halt -p at the end of shutdown) is the default halt action: the only way to achieve halt without poweroff is to use the upper-case -H option of the shutdown command to explicitly request it, e.g. shutdown -hH now
But again, the default powerdown is triggered by the runlevel scripts customized by the Linux distribution, so it's not really a feature of the SysVinit halt command.
Historical note
Old SysVinit-using systems (both Linux and non) used to have several commands that were not intended to be used directly, but only as part of the appropriate shutdown/reboot scripts. Before SysVinit 2.74, the /sbin/halt command with no options would have done the same as halt -f of modern SysVinit does, i.e. a brutal, immediate kernel shutdown without stopping any services or unmounting filesystems.
For the same reason, being used to the Linux killall command can be dangerous on other Unixes. Its man page even has this ominous warning:
Be warned that typing killall name may not have the desired effect on non-Linux systems, especially when done by a privileged user.
This is because the classic SystemV killall was one of those commands designed to be used only as part of a shutdown script. In Linux distributions with SysVinit, the classic version of the command may be found as killall5. It literally kills all processes except kernel threads and processes in its own session: its intended use is in a shutdown script after shutting down all services, just before unmounting the local filesystems, to kill of any other processes that might delay or prevent the unmounting.
(How I know this, you ask? Well, I once made the mistake of running killall <something> as root on a Solaris 2.6 system. A very effective learning experience.)
edited 6 hours ago
answered 7 hours ago
telcoMtelcoM
19.3k12448
19.3k12448
Yes that is what I am expecting! Very nice informations! Thank you a lot, specially about the notes about Red Hat doing the same behavior in older versions!
– Luciano Andress Martini
5 hours ago
add a comment |
Yes that is what I am expecting! Very nice informations! Thank you a lot, specially about the notes about Red Hat doing the same behavior in older versions!
– Luciano Andress Martini
5 hours ago
Yes that is what I am expecting! Very nice informations! Thank you a lot, specially about the notes about Red Hat doing the same behavior in older versions!
– Luciano Andress Martini
5 hours ago
Yes that is what I am expecting! Very nice informations! Thank you a lot, specially about the notes about Red Hat doing the same behavior in older versions!
– Luciano Andress Martini
5 hours ago
add a comment |
This question is predicated upon multiple falsehoods.
One did not use halt to turn off one's computer, and this has not changed with systemd.
halt a.k.a. haltsys shuts down and halts. poweroff is a newer command that shuts down and powers off. (https://unix.stackexchange.com/a/196471/5132 explains the subtleties of this which I am going to gloss over here, since the question is only about Linux operating systems. This answer focuses on just the AT&T System 5 UNIX side of the universe.)
As I explained at https://superuser.com/a/900205/38062, computers are not necessarily able to power off under software control. The action of the haltsys and halt command has conventionally been to shutdown and halt the machine, the next action being the operator using a physical reset button or power switch.
halt gained a -p/--poweroff option to make it equivalent to poweroff, but this is symptomatic of a general growth of overlapping and self-contradictory options to these commands. Witness the manual page for the Upstart halt command in Debian 7. There's halt --poweroff there. The manual page for the van Smoorenburg halt command in Debian 7 similarly has halt -p.
But this is not something that has changed with systemd. systemd provides the same. The systemd halt command also has --poweroff. It furthermore has --reboot and (for good measure) --halt options.
I had to do the same with the halt/haltsys command in the nosh toolset, for compatibility.
You may erroneously think that plain old halt powered off your computer. But that was unequivocally wrong for Upstart, and only true for the van Smoorenburg toolset if you happened to hit a bug.
The bug, which has only this year finally been fixed, was that the van Smoorenburg halt command would simply ignore the presence or absence of the -p option and instead decide whether to halt or power off according to the value of a setting in /etc/default/halt. If you happened to have that setting set to power off, then halt would always power off, even if no -p option were supplied. Conversely, if you happened to have that setting set to halt, then halt would always halt, even if a -p option were supplied.
But this was a bug, not the documented nor intended behaviour, not the behaviour of every halt command that was available on Debian, and not the conventional behaviour of the halt command in general.
Further reading
- Jonathan de Boyne Pollard (2018-12-07). Bug#586709: closed by Thomas Goirand. Debian bug #586709.
- Jessie Smith (2019-03-08). initscripts: command
haltunintended changed behaviour. Debian bug #743555.
A falsehood that running apt install sysvinit-core turned true! Why? I just installed sysvinit, and at end halt says "Will now halt" exactly in that moment the machine powered off, how could this be a falsehood, it looks like the developer of sysvinit still has this falsehood! and plus that halt -f turns off the machine immediately.
– Luciano Andress Martini
11 hours ago
1
When using SysVinit in Debian(esque) systems,/etc/defaults/haltincludes a variable that defines whether the system will runhaltorpoweroffat the end of transition to runlevel 0. The default setting isHALT=poweroff. Before SysVinit 2.74 you were not supposed to runhaltdirectly, and starting from that version, the SysVinithaltcommand will just callshutdown -hunless the current runlevel is 0 or 6. This is documented inhalt(8)man page. At the end of transition to runlevel 0 the runlevel scripts will run$HALT, which is equal topoweroffby default.
– telcoM
10 hours ago
1
@telcoM Thank you very much for this! That is enough for me, if you put that as a answer I will mark it as the correct answer. (Note one thing (not very important), CentOS seems to have the same behavior in my old servers). Can you post this as a answer please?
– Luciano Andress Martini
8 hours ago
add a comment |
This question is predicated upon multiple falsehoods.
One did not use halt to turn off one's computer, and this has not changed with systemd.
halt a.k.a. haltsys shuts down and halts. poweroff is a newer command that shuts down and powers off. (https://unix.stackexchange.com/a/196471/5132 explains the subtleties of this which I am going to gloss over here, since the question is only about Linux operating systems. This answer focuses on just the AT&T System 5 UNIX side of the universe.)
As I explained at https://superuser.com/a/900205/38062, computers are not necessarily able to power off under software control. The action of the haltsys and halt command has conventionally been to shutdown and halt the machine, the next action being the operator using a physical reset button or power switch.
halt gained a -p/--poweroff option to make it equivalent to poweroff, but this is symptomatic of a general growth of overlapping and self-contradictory options to these commands. Witness the manual page for the Upstart halt command in Debian 7. There's halt --poweroff there. The manual page for the van Smoorenburg halt command in Debian 7 similarly has halt -p.
But this is not something that has changed with systemd. systemd provides the same. The systemd halt command also has --poweroff. It furthermore has --reboot and (for good measure) --halt options.
I had to do the same with the halt/haltsys command in the nosh toolset, for compatibility.
You may erroneously think that plain old halt powered off your computer. But that was unequivocally wrong for Upstart, and only true for the van Smoorenburg toolset if you happened to hit a bug.
The bug, which has only this year finally been fixed, was that the van Smoorenburg halt command would simply ignore the presence or absence of the -p option and instead decide whether to halt or power off according to the value of a setting in /etc/default/halt. If you happened to have that setting set to power off, then halt would always power off, even if no -p option were supplied. Conversely, if you happened to have that setting set to halt, then halt would always halt, even if a -p option were supplied.
But this was a bug, not the documented nor intended behaviour, not the behaviour of every halt command that was available on Debian, and not the conventional behaviour of the halt command in general.
Further reading
- Jonathan de Boyne Pollard (2018-12-07). Bug#586709: closed by Thomas Goirand. Debian bug #586709.
- Jessie Smith (2019-03-08). initscripts: command
haltunintended changed behaviour. Debian bug #743555.
A falsehood that running apt install sysvinit-core turned true! Why? I just installed sysvinit, and at end halt says "Will now halt" exactly in that moment the machine powered off, how could this be a falsehood, it looks like the developer of sysvinit still has this falsehood! and plus that halt -f turns off the machine immediately.
– Luciano Andress Martini
11 hours ago
1
When using SysVinit in Debian(esque) systems,/etc/defaults/haltincludes a variable that defines whether the system will runhaltorpoweroffat the end of transition to runlevel 0. The default setting isHALT=poweroff. Before SysVinit 2.74 you were not supposed to runhaltdirectly, and starting from that version, the SysVinithaltcommand will just callshutdown -hunless the current runlevel is 0 or 6. This is documented inhalt(8)man page. At the end of transition to runlevel 0 the runlevel scripts will run$HALT, which is equal topoweroffby default.
– telcoM
10 hours ago
1
@telcoM Thank you very much for this! That is enough for me, if you put that as a answer I will mark it as the correct answer. (Note one thing (not very important), CentOS seems to have the same behavior in my old servers). Can you post this as a answer please?
– Luciano Andress Martini
8 hours ago
add a comment |
This question is predicated upon multiple falsehoods.
One did not use halt to turn off one's computer, and this has not changed with systemd.
halt a.k.a. haltsys shuts down and halts. poweroff is a newer command that shuts down and powers off. (https://unix.stackexchange.com/a/196471/5132 explains the subtleties of this which I am going to gloss over here, since the question is only about Linux operating systems. This answer focuses on just the AT&T System 5 UNIX side of the universe.)
As I explained at https://superuser.com/a/900205/38062, computers are not necessarily able to power off under software control. The action of the haltsys and halt command has conventionally been to shutdown and halt the machine, the next action being the operator using a physical reset button or power switch.
halt gained a -p/--poweroff option to make it equivalent to poweroff, but this is symptomatic of a general growth of overlapping and self-contradictory options to these commands. Witness the manual page for the Upstart halt command in Debian 7. There's halt --poweroff there. The manual page for the van Smoorenburg halt command in Debian 7 similarly has halt -p.
But this is not something that has changed with systemd. systemd provides the same. The systemd halt command also has --poweroff. It furthermore has --reboot and (for good measure) --halt options.
I had to do the same with the halt/haltsys command in the nosh toolset, for compatibility.
You may erroneously think that plain old halt powered off your computer. But that was unequivocally wrong for Upstart, and only true for the van Smoorenburg toolset if you happened to hit a bug.
The bug, which has only this year finally been fixed, was that the van Smoorenburg halt command would simply ignore the presence or absence of the -p option and instead decide whether to halt or power off according to the value of a setting in /etc/default/halt. If you happened to have that setting set to power off, then halt would always power off, even if no -p option were supplied. Conversely, if you happened to have that setting set to halt, then halt would always halt, even if a -p option were supplied.
But this was a bug, not the documented nor intended behaviour, not the behaviour of every halt command that was available on Debian, and not the conventional behaviour of the halt command in general.
Further reading
- Jonathan de Boyne Pollard (2018-12-07). Bug#586709: closed by Thomas Goirand. Debian bug #586709.
- Jessie Smith (2019-03-08). initscripts: command
haltunintended changed behaviour. Debian bug #743555.
This question is predicated upon multiple falsehoods.
One did not use halt to turn off one's computer, and this has not changed with systemd.
halt a.k.a. haltsys shuts down and halts. poweroff is a newer command that shuts down and powers off. (https://unix.stackexchange.com/a/196471/5132 explains the subtleties of this which I am going to gloss over here, since the question is only about Linux operating systems. This answer focuses on just the AT&T System 5 UNIX side of the universe.)
As I explained at https://superuser.com/a/900205/38062, computers are not necessarily able to power off under software control. The action of the haltsys and halt command has conventionally been to shutdown and halt the machine, the next action being the operator using a physical reset button or power switch.
halt gained a -p/--poweroff option to make it equivalent to poweroff, but this is symptomatic of a general growth of overlapping and self-contradictory options to these commands. Witness the manual page for the Upstart halt command in Debian 7. There's halt --poweroff there. The manual page for the van Smoorenburg halt command in Debian 7 similarly has halt -p.
But this is not something that has changed with systemd. systemd provides the same. The systemd halt command also has --poweroff. It furthermore has --reboot and (for good measure) --halt options.
I had to do the same with the halt/haltsys command in the nosh toolset, for compatibility.
You may erroneously think that plain old halt powered off your computer. But that was unequivocally wrong for Upstart, and only true for the van Smoorenburg toolset if you happened to hit a bug.
The bug, which has only this year finally been fixed, was that the van Smoorenburg halt command would simply ignore the presence or absence of the -p option and instead decide whether to halt or power off according to the value of a setting in /etc/default/halt. If you happened to have that setting set to power off, then halt would always power off, even if no -p option were supplied. Conversely, if you happened to have that setting set to halt, then halt would always halt, even if a -p option were supplied.
But this was a bug, not the documented nor intended behaviour, not the behaviour of every halt command that was available on Debian, and not the conventional behaviour of the halt command in general.
Further reading
- Jonathan de Boyne Pollard (2018-12-07). Bug#586709: closed by Thomas Goirand. Debian bug #586709.
- Jessie Smith (2019-03-08). initscripts: command
haltunintended changed behaviour. Debian bug #743555.
answered Mar 15 at 1:16
JdeBPJdeBP
37.2k476177
37.2k476177
A falsehood that running apt install sysvinit-core turned true! Why? I just installed sysvinit, and at end halt says "Will now halt" exactly in that moment the machine powered off, how could this be a falsehood, it looks like the developer of sysvinit still has this falsehood! and plus that halt -f turns off the machine immediately.
– Luciano Andress Martini
11 hours ago
1
When using SysVinit in Debian(esque) systems,/etc/defaults/haltincludes a variable that defines whether the system will runhaltorpoweroffat the end of transition to runlevel 0. The default setting isHALT=poweroff. Before SysVinit 2.74 you were not supposed to runhaltdirectly, and starting from that version, the SysVinithaltcommand will just callshutdown -hunless the current runlevel is 0 or 6. This is documented inhalt(8)man page. At the end of transition to runlevel 0 the runlevel scripts will run$HALT, which is equal topoweroffby default.
– telcoM
10 hours ago
1
@telcoM Thank you very much for this! That is enough for me, if you put that as a answer I will mark it as the correct answer. (Note one thing (not very important), CentOS seems to have the same behavior in my old servers). Can you post this as a answer please?
– Luciano Andress Martini
8 hours ago
add a comment |
A falsehood that running apt install sysvinit-core turned true! Why? I just installed sysvinit, and at end halt says "Will now halt" exactly in that moment the machine powered off, how could this be a falsehood, it looks like the developer of sysvinit still has this falsehood! and plus that halt -f turns off the machine immediately.
– Luciano Andress Martini
11 hours ago
1
When using SysVinit in Debian(esque) systems,/etc/defaults/haltincludes a variable that defines whether the system will runhaltorpoweroffat the end of transition to runlevel 0. The default setting isHALT=poweroff. Before SysVinit 2.74 you were not supposed to runhaltdirectly, and starting from that version, the SysVinithaltcommand will just callshutdown -hunless the current runlevel is 0 or 6. This is documented inhalt(8)man page. At the end of transition to runlevel 0 the runlevel scripts will run$HALT, which is equal topoweroffby default.
– telcoM
10 hours ago
1
@telcoM Thank you very much for this! That is enough for me, if you put that as a answer I will mark it as the correct answer. (Note one thing (not very important), CentOS seems to have the same behavior in my old servers). Can you post this as a answer please?
– Luciano Andress Martini
8 hours ago
A falsehood that running apt install sysvinit-core turned true! Why? I just installed sysvinit, and at end halt says "Will now halt" exactly in that moment the machine powered off, how could this be a falsehood, it looks like the developer of sysvinit still has this falsehood! and plus that halt -f turns off the machine immediately.
– Luciano Andress Martini
11 hours ago
A falsehood that running apt install sysvinit-core turned true! Why? I just installed sysvinit, and at end halt says "Will now halt" exactly in that moment the machine powered off, how could this be a falsehood, it looks like the developer of sysvinit still has this falsehood! and plus that halt -f turns off the machine immediately.
– Luciano Andress Martini
11 hours ago
1
1
When using SysVinit in Debian(esque) systems,
/etc/defaults/halt includes a variable that defines whether the system will run halt or poweroff at the end of transition to runlevel 0. The default setting is HALT=poweroff. Before SysVinit 2.74 you were not supposed to run halt directly, and starting from that version, the SysVinit halt command will just call shutdown -h unless the current runlevel is 0 or 6. This is documented in halt(8) man page. At the end of transition to runlevel 0 the runlevel scripts will run $HALT, which is equal to poweroff by default.– telcoM
10 hours ago
When using SysVinit in Debian(esque) systems,
/etc/defaults/halt includes a variable that defines whether the system will run halt or poweroff at the end of transition to runlevel 0. The default setting is HALT=poweroff. Before SysVinit 2.74 you were not supposed to run halt directly, and starting from that version, the SysVinit halt command will just call shutdown -h unless the current runlevel is 0 or 6. This is documented in halt(8) man page. At the end of transition to runlevel 0 the runlevel scripts will run $HALT, which is equal to poweroff by default.– telcoM
10 hours ago
1
1
@telcoM Thank you very much for this! That is enough for me, if you put that as a answer I will mark it as the correct answer. (Note one thing (not very important), CentOS seems to have the same behavior in my old servers). Can you post this as a answer please?
– Luciano Andress Martini
8 hours ago
@telcoM Thank you very much for this! That is enough for me, if you put that as a answer I will mark it as the correct answer. (Note one thing (not very important), CentOS seems to have the same behavior in my old servers). Can you post this as a answer please?
– Luciano Andress Martini
8 hours ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f506341%2fdebian-9-halt-does-not-really-power-off-in-new-versions-why%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Plain
haltpowers off a macOS system, but not an OpenBSD system.haltis not a POSIX utility, nor ispowerofforshutdownor any similar utility.– Kusalananda
Mar 14 at 18:30
Not duplicated, because halt can power off Debian 8 for example. I just dont understand why removing that behavior!
– Luciano Andress Martini
Mar 14 at 18:41
1
@DopeGhoti I don't think this is a dupe. The OP wants to know why this change happened, not what the difference between
haltandshutdownmay be.– terdon♦
Mar 14 at 19:10
1
Yes, exactly, I am trying to understand why this change happened. Thank you.
– Luciano Andress Martini
Mar 14 at 19:35
1
haltallows for the system to be halted with diagnostic kernel messages still visible on the console on some systems; this is the reason for a distinction betweenhaltandpoweroffto exist at all.– DopeGhoti
Mar 14 at 21:42