LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-10-2017, 09:22 AM   #1
badbetty
Member
 
Registered: Jan 2014
Posts: 159

Rep: Reputation: Disabled
what is the default powerstate (e.g. S3,S4,S5) for the command 'shutdown -hP' or 'shutdown -hH' or 'shutdown -h'


I've done some reading today and screwed my head off :-)

It all started with trying to understand the shutdown command and the [subtle] differences between shutdown -h, shutdown -hP and shutdown -hH.

Further; in some moment of madness believing that -hP would shutdown and poweroff and leave no power to any devices...as in properly power down. Alternatively, just issuing the -h would halt the system and leave some power to some devices e.g. the eth/nic card (for wake up perhaps).

Then I revisited the 'ethtool' command with regard to wake-up-on-lan (wol) settings (enabled 'g' and disable 'd') and whether these affected the above, or were affected by the above.

It was all in an attempt to understand that if the eth/nic card is set to wol, then if I issue a shutdown -h, the computer shutsdown to S5 state leaving some power to the card for wake up purposes, but if issued a shutdown -hP then it shutsdown and thats' that...is unwakeable.

Well I could not establish there was any relationship between the wol setting of the nic/eth card and shutdown. The ethtool appears to only set/unset whether the card will comply with any wol request.

Shutdown -hP or -h does not affect whether the machine will or will not wakeup. ie, any shutdown command will always leave power to the ethcard, so that if the eth card is set to obey wake up it will.

Therefore my subject question is: can anyone concur, elaborate, correct that the default state for shutdown is S5 and that it is not possible to fully power down the machine (can only be done by manually switching it off so to speak) ?

Thank you for any comments on this.

PS: I can also envisage that this all this may be hardware/driver dependent too! ho hum :-)

PPS: i never could establish a clear understanding (by observation) what -hH was supposed to do either.

Last edited by badbetty; 11-10-2017 at 09:23 AM.
 
Old 11-10-2017, 07:49 PM   #2
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
I'm not aware that the standard (unmodified) Linux shutdown command (utility) is able to put the Hardware in a preferred power state.
Here you have the man page of shutdown:
https://linux.die.net/man/8/shutdown

The "S3,S4,S5" power states you've mentioned are related to the sleep modes and it looks to be the old implementation:
http://acpi.sourceforge.net/documentation/sleep.html
The new implementation you can find here:
https://www.kernel.org/doc/html/v4.1...ep-states.html

The modern PM control is achieved directly in the kernel through /sys/power/state
Careful, since the new PM advanced control implementations are not really well documented / closed source / changing between releases you might encounter support issues under Linux (kernel) and you should always check if your running kernel supports the PM of your HW platform (Chipset) before starting using it.

You should use the pm-utils for your PM needs. They are available in Slackware and like a typical modern freedesktop.org project they lack proper documentation:
https://pm-utils.freedesktop.org/wiki/
The Wiki points to an unavailable OpenSUSE Wiki, which you can finally find over here:
https://old-en.opensuse.org/Pm-utils
Here you can get all the pm-utils utilities listed with a short description:
http://www.linuxfromscratch.org/blfs.../pm-utils.html

The official Slackware PM page is also really helpful:
https://docs.slackware.com/howtos:sl...in:hibernation

Personally, I'm staying away from any form of advanced PM under Linux and if I need some wake-on-LAN function, or such, then I'd prefer to properly shut down the system and let the BIOS (configure it) handle it. Power consumption wise it's the best solution and I'm patient enough to wait some tens of seconds for the system to come up (OS to load).

Now, as I understand, you are deliberately willing to put your system in a form of suspend/hibernation mode and wake it through the ethernet adapter. You are right, the HW&driver of that ethernet adapter needs to have the WoL implemented and properly functional (some don't) and here are some guides that are easily translatable into Linux, which Slackware still is, that you can follow:
https://a3nm.net/blog/wakeonlan.html
https://www.cyberciti.biz/tips/linux...c-packets.html
https://blog.shichao.io/2013/11/10/w..._ethernet.html

Last edited by abga; 11-10-2017 at 07:55 PM. Reason: PM - kernel support addendum
 
1 members found this post helpful.
Old 11-11-2017, 04:35 AM   #3
badbetty
Member
 
Registered: Jan 2014
Posts: 159

Original Poster
Rep: Reputation: Disabled
@abga many thanks for the reply, I will plough through the links and enlighten myself.

I suppose the whole exercise is about trying to understand if /sbin/shutdown -hP really does power off the machine completely, or if it still leaves power to the eth/nic card - which may very well be set to allow a 'wakeup' (assuming that function has not been disabled in some manner). Of course if the power switch is operated, then its off no question.

Currently for two machines I'm 'playing' with, it would seem that shutdown -hP always leaves it possible to wake the machines up *but* that's depending on whether the eth card wake-on-lan is active/disable (if the BIOS is set to allow rmeote wake too of course).

Thanks again. Once thing for sure, there is documentation about and plenty of posts on forums asking similar questions about how it all works, *but* as you say...a lot of it is not let's say fully and clearly documented. :-)
 
Old 11-11-2017, 01:51 PM   #4
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
@badbetty

My original post was initially longer and I considered to edit it to protect your already "screwed neurons", cut some introductory details and links, and also due to the fact that I got myself bored reading through it . I'm sorry now about that as I see you're still a little bit confused and "obsessively" focused on the shutdown command.

First, some basic HW facts about the BIOS / PM / APM / ACPI:
- the BIOS has it's own HW PM subsystem that is independent and autonomous, powered even if the computer is powered off but still connected to the power line / has a charged battery in case of a mobile computer.
https://en.wikipedia.org/wiki/Power_management
- this BIOS PM autonomous subsystem has an interface (API) implemented to connect and communicate with the operating system (Windows/Linux/MacOS...etc) which is called APM (first implementation) and ACPI (latest implementation):
https://en.wikipedia.org/wiki/Advanced_power_management
https://en.wikipedia.org/wiki/Advanc...ower_Interface

Focusing only on Linux and its kernel (Slackware in our case), you should realize that there were a lot of changes during its development, first covering APM and lately ACPI. That's why you'll find a lot of obsolete/confusing information on the Internet.

To understand the old shutdown command and how it works I can provide you with some clues:
- again, the shutdown command is by itself not designed to handle directly the APM/ACPI but only to call the init system (process) which in turn is executing the Linux system shutdown script and provide (pass over) it with the variable (option) with which shutdown was executed. In Slackware's case this shutdown script is /etc/rc.d/rc.6
- a short excerpt from the shutdown man page covering the -H switch:
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.
- the snippet of /etc/rc.d/rc.6 that handles the shutdown command an its variable:
Code:
# Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
if [ "$shutdown_command" = "reboot" ]; then
  echo "Rebooting."
  /sbin/reboot
else
  /sbin/poweroff
fi
- as you can see, in case of a shutdown it is calling /sbin/poweroff which is telling the BIOS (through the APMD/ACPID - kernel support)to cut the power

For what you want to achieve, you have two options, either shut down the system entirely with the shutdown command and use the BIOS WoL capabilities to handle the wake up and loading of the OS. This is the most simple and safe alternative.
Or, use the more "exotic" power states like suspend to RAM or hibernation, from which states the system is recovering faster (doesn't need to boot and load the OS), by calling them through APM/ACPI, in which the system is not really powered off but in a very low power consuming state, and use pm-utils to trigger them. Even in this case you still need to configure (turn on) the WoL capabilities in BIOS. Additional to this PM call you need to set your NIC to enable and accept WoL under Linux. As stated above, the shutdown command isn't of any help here because it only tells init what to do and not the BIOS (through APM/ACPI).

Just to make sure your neurons are "unscrewed", I'm detailing (again) the way this OS-BIOS communication is done nowadays.
The ACPI support is implemented (embedded) in the kernel and is controllable through the /sys/power/ directory and the acpid daemon - the most appropriate tools to talk to this system are the pm-tools. Obviously, if you know what you're doing, you can manually tune the power states by editing the values in /sys/power/ but I wouldn't encourage that:
https://www.kernel.org/doc/Documenta.../interface.txt
https://www.kernel.org/doc/Documenta...-debugging.txt

A last note, if you go for hibernation on Slackware, then you need to setup a partition where the RAM contents will be saved and you should follow this guide:
https://docs.slackware.com/howtos:sl...in:hibernation

Last edited by abga; 11-11-2017 at 05:33 PM. Reason: apparently only one typo! Added the forgotten WoL BIOS setup requirements for suspend/hibernate - autocorrected apmd - acpid
 
Old 11-11-2017, 06:16 PM   #5
badbetty
Member
 
Registered: Jan 2014
Posts: 159

Original Poster
Rep: Reputation: Disabled
@abga thankyou for your comments...wow. Gosh, it was never my intention to cause any impression to reason that I am obsessing over this power off study :-)

Now I may have to go over it *all* again to see if I actually am ;-)...rather than trying just to better my current understanding in relation to my recent experiences on the subject.


No harm done...yet hehe...but the machines are well fedup of being run up and down every so often in my quest for enlightenment.

Why do I do it.

My tongue in cheek aside, I will assimilate best I can what you have said. Thank you.
 
Old 11-11-2017, 06:41 PM   #6
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
Quote:
I suppose the whole exercise is about trying to understand if /sbin/shutdown -hP really does power off the machine completely, or if it still leaves power to the eth/nic card - which may very well be set to allow a 'wakeup' (assuming that function has not been disabled in some manner).
<EDIT - more explicit about the HW BIOS setup>
Disregarding the shutdown command part, the exercise is to understand that the BIOS PM, which is autonomous and handles by itself the WoL, needs to be configured first (enable the WoL in your case through the BIOS setup at your system power-on screen) and let it know that even if you asked it to enter a suspend/hibernate mode with the pm-utils you want it to be ready to respond to a WoL call on a specific device form a specific subsystem (USB/PCI) and bring the system back online. That's what you achieve by enabling the WoL on the NIC driver in the Operating System with ethtool before calling the system suspend/hibernation. Apparently these states, depending on the capabilities of your BIOS PM, are to be found and enabled in the /proc/acpi/wakeup directory.
More info:
https://unix.stackexchange.com/quest...s-code-meaning
https://unix.stackexchange.com/quest...rom-the-kernel

For more details about the BIOS ACPI kernel stuff you can go through the relevant kernel source code or register at kernel.org and "annoy" the developers with some questions

You see, that's why I prefer to shut down the system, don't mess around with the OS PM support which is continuously under development, and only configure and use the BIOS WoL capabilities in case I need to wake a system from the dead. It's simpler and it works all the time. With suspend/hibernation some things (physical/electronic events) can also go wrong and you might end up with a fast-recovering but crippled system.

<EDIT - to avoid any misunderstandings>
(last post I promise, before it'll get really boring )

Last edited by abga; 11-12-2017 at 12:12 AM. Reason: typo - 2 x EDIT for clarification
 
Old 11-12-2017, 12:18 AM   #7
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
I was confused by your original post and considered to guide you on your two possibilities to achieve WoL, putting the preference on the simpler HW BIOS one.

Try to make sense of these two statements:
Quote:
It was all in an attempt to understand that if the eth/nic card is set to wol, then if I issue a shutdown -h, the computer shutsdown to S5 state leaving some power to the card for wake up purposes, but if issued a shutdown -hP then it shutsdown and thats' that...is unwakeable.
&
Quote:
Shutdown -hP or -h does not affect whether the machine will or will not wakeup. ie, any shutdown command will always leave power to the ethcard, so that if the eth card is set to obey wake up it will.
Again, the two possibilities to obtain WoL are:
1. The HW BIOS only way - totally disregarding the OS
2. The OS way - suspend/hibernate where the BIOS itself needs to be configured and WoL enabled (through the BIOS setup interface at the power-on screen of your computer), the NIC needs to have its WoL activated under Linux with ethtool and finally your desired state (suspend/hibernation) called with the help of pm-utils under Linux

If you opt for the first possibility (I highly recommend it) and set the WoL in your BIOS - through the BIOS configuration interface at the boot-up of your computer, then you shouldn't need to worry about the Linux PM at all and only gracefully shut down your Linux all the time with:
Code:
shutdown -h now
(I never used any other command to gracefully shutdown a Slackware (other Linux systems too) for almost 20 years now...)

If you turn off your computer from the power-off physical button (ungracefully), you might then have some issues with the WoL as I found this reported on some forums for some specific motherboards.

If you still cannot get the WoL BIOS functionality you expect, check if you have a BIOS update first and please do come back here and confuse me/us more

Last edited by abga; 11-12-2017 at 12:22 AM. Reason: pm-tools = pm-utils
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] system failed to save session at shutdown, but retrieved changes after next shutdown - ?! newbiesforever Linux - General 5 06-09-2016 09:58 PM
[SOLVED] shutdown works, but /lib/systemd/system/shutdown.target does not. kaz2100 Debian 3 08-06-2014 03:28 AM
FC18: running a command on shutdown (or reboot) before every other shutdown operation P5music Fedora 3 04-23-2013 03:56 PM
Where I can locate Shutdown log for Linux Shutdown (RHL 5.1-2.6.18-53.el5PAE) msmallya Linux - General 2 04-23-2010 01:56 AM
'shutdown' command causing unclean shutdown silentwol Linux - Software 3 07-01-2009 02:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration