cannot be configured to not hibernate if hardware supports it
Steps to reproduce
Configure GNOME to suspend (to RAM) on idle, when the suspend key is pressed (this used to be configurable but is not in 3.29) and/or when the power key is pressed
Expected result
Machine suspends to RAM (only)
Actual result
Machine sometimes suspends to disk (hibernates) anyway
When configured to suspend, recent versions of g-s-d try to use a suspend-then-hibernate behaviour in which the machine suspends to RAM, but sets a real-time-clock timer to wake itself up and hibernate (suspend to disk).
Hibernation seems like something that is not necessarily always desirable:
- Waking up correctly from hibernation has historically not been amazingly reliable on at least some hardware, leading to data loss.
- The machine might wake up from suspend-to-RAM in a situation where it is undesirable for it to be running, for example being carried in a backpack with no ventilation possible. If hibernation fails, it could end up continuing to run and becoming dangerously hot.
- Similarly, if the machine has a spinning hard disk, it might wake up in a situation where jolting can lead to damage to the disk, for example being carried in a backpack.
- If a new kernel has been installed since the most recent boot, most bootloaders will try to boot that instead of the boot kernel, and resume will fail, leading to data loss.
- Hibernation effectively swaps out everything from RAM, including pages that have been locked into memory with
mlock()
or similar, which might contain unencrypted secrets that should not be written to disk. (Yes, full-disk encryption exists, but for hibernation to be successful, the encryption key has to be persistent, so there is no forward secrecy available here.)
systemd implements CanSuspendThenHibernate()
in terms of whether it is physically possible to use the suspend-then-hibernate (whenever enough swap is available, it is assumed to be possible to hibernate), which suggests that the place to implement "hibernate is physically possible but forbidden by configuration" would be gnome-settings-daemon rather than systemd.
systemd itself does not use suspend-then-hibernate by default: logind's defaults are HandleSuspendKey=suspend
, HandlePowerKey=poweroff
, HandleHibernateKey=hibernate
, HandleLidSwitch=suspend
, HandleLidSwitchExternalPower=suspend
and HandleLidSwitchDocked=ignore
.
The simplest possible UI for this would probably be:
Automatic suspend On
Use hibernation (suspend to disk) [ON | [ ]] <-- new
When power button is pressed [Suspend |v]
| Suspend |
| Power off |
| Hibernate |
| Nothing |
|-------------------------|
Another possibility would be something like:
Automatic suspend On
When suspend button is pressed [Suspend |v] <-- new
| Suspend |
| Suspend, then hibernate |
|-------------------------|
When power button is pressed [Suspend |v]
| Suspend |
| Suspend, then hibernate | <-- new
| Power off |
| (etc.) |
|-------------------------|