View previous topic :: View next topic |
Author |
Message |
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Thu Feb 04, 2016 12:06 pm Post subject: TIP: suspend to ram without complicated setup |
|
|
I've tried most of the suspend packages in portage, and while they get the job done, I never quite understood what the need for all the magic was. So I went digging to find the secret sauce under it all.
And as it turns out, most of the time all that's necessary for decent system suspend is...
Code: | su -c 'echo mem > /sys/power/state' |
...and if you have a laptop, you can just bind that command to the suspend hotkey via acpid (no su needed there) and get the fastest suspend/resume your hardware is capable of. System services like wpa_supplicant and dhcpcd are generally well-behaved and don't need handholding through suspend cycles, though I'd advise you to do a few test runs and check `dmesg -H`, `rc-status` and syslog afterwards for weirdness; not all software is as robust.
In my own experience, I've found that sshfs filesystems are over-eager to time out and don't auto-reconnect (fixable if I'd set up autofs), and I have a sound card that doesn't cooperate with ACPI PM at all. This is what I use on my desktop to handle that:
Code: | /usr/bin/pasuspender -- su -c '/sbin/rmmod snd-au8830 && printf mem >| /sys/power/state && /sbin/modprobe snd-au8830' |
If you have difficult hardware and nothing seems to work, an alternative is `echo freeze > /sys/power/state`. This doesn't use ACPI, it just stops processes running and tries to invoke all of Linux's runtime power saving mechanisms at once. Not nearly as effective on a desktop but it might still be handy as a last resort. |
|
Back to top |
|
|
frostschutz Advocate
Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Thu Feb 04, 2016 12:16 pm Post subject: |
|
|
Quote: | I never quite understood what the need for all the magic was. |
I need at least two tiny bits of magic:
1) sync before suspend, so in the event of a power loss, severe filesystem damage is a bit less likely. this is also the main reason why suspend takes a second or two if there are outstanding writes...
2) restart hdparm on wakeup, as otherwise disks won't go into standby anymore, for those of us that still use HDDs |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3134
|
Posted: Thu Feb 04, 2016 5:04 pm Post subject: |
|
|
Good hint, so easily forgotten those days
A bit of magic for services that misbehave after resuming:
Code: |
cat /etc/pm/sleep.d/hostapd
#! /bin/bash
if /etc/init.d/hostapd status
then /etc/init.d/hostapd restart
fi
|
|
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Thu Feb 04, 2016 10:13 pm Post subject: |
|
|
frostschutz wrote: | 2) restart hdparm on wakeup, as otherwise disks won't go into standby anymore, for those of us that still use HDDs |
Good point, I tend to leave most of my hardware at defaults. Seems like ethtool mtu settings stick over a suspend at least. |
|
Back to top |
|
|
Yamakuzure Advocate
Joined: 21 Jun 2006 Posts: 2284 Location: Adendorf, Germany
|
Posted: Fri Feb 05, 2016 7:46 am Post subject: |
|
|
emerge "sys-power/hibernate-script", set your user to be allowed to call it without a password and all you ever have to do is No magic, no bells, no whistles. _________________ Important German:- "Aha" - German reaction to pretend that you are really interested while giving no f*ck.
- "Tja" - German reaction to the apocalypse, nuclear war, an alien invasion or no bread in the house.
|
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Fri Feb 05, 2016 9:04 am Post subject: Re: TIP: suspend to ram without complicated setup |
|
|
Ant P. wrote: | I've tried most of the suspend packages in portage, and while they get the job done, I never quite understood what the need for all the magic was. So I went digging to find the secret sauce under it all. |
Ant ... ahhh, but as the story goes, that secret sauce has a secret ingredient ... ad infinatum ;)
Ant P. wrote: | ...and if you have a laptop, you can just bind that command to the suspend hotkey via acpid (no su needed there) and get the fastest suspend/resume your hardware is capable of. System services like wpa_supplicant and dhcpcd are generally well-behaved and don't need handholding through suspend cycles, though I'd advise you to do a few test runs and check `dmesg -H`, `rc-status` and syslog afterwards for weirdness; not all software is as robust. |
In case anyone does have an issue ITR, they can use 'if wpa_cli ping ; then wpa_cli suspend' and 'wpa_cli resume' subsequently. This should cause wpa_supplicant to check the connection, and re-associate if necessary ... though if there is an issue in suspending wireless its more likely to be the driver than wpa_supplicant itself.
Ant P. wrote: | In my own experience, I've found that sshfs filesystems are over-eager to time out and don't auto-reconnect (fixable if I'd set up autofs), and I have a sound card that doesn't cooperate with ACPI PM at all. This is what I use on my desktop to handle that:
Code: | /usr/bin/pasuspender -- su -c '/sbin/rmmod snd-au8830 && printf mem >| /sys/power/state && /sbin/modprobe snd-au8830' |
|
That in part is why the likes of hibernate.sh exist, such things can be added to 'Unmount', 'UnmountFSTypes', etc, modules unloaded/reloaded, services stopped/started, etc. There are other features such as '--no-suspend' and logging, for testing and debugging, which are useful when things don't work as expected. So, yes, none of that may be strictly needed but they can save you some effort, and time, when some secret ingredient is missing ;)
best ... khay |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|