Re: how to let systemd hibernate start/stop the swap area?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mi, 29.03.23 04:43, Christoph Anton Mitterer (calestyo@xxxxxxxxxxxx) wrote:

Hi!

> I guess many people nowadays will run without any swap for the normal
> paging use, but only have it for hibernation (at least on laptops).

That's a bad idea btw. I'd advise you not to do that: on modern
systems you want swap, since it makes anonymous memory reclaimable. I
am not sure where you are getting this idea from that swap was
bad. It's *good*. Things like systemd-oomd will even warn if you don't
have swap, as it amplifies memory pressure as swap-less systems can
only swap out file-backed memory instead of anything anonymous.

> That does work, when:
>    # systemctl start systemd-hibernate.service
> but it doesn't when:
>    # systemctl hibernate
> which I don't understand, since I though that would start the target,
> which would pull in and thus start the service, which before pulls in
> starts my swapfile.

Provide debug logs of PID1, i.e. "systemd-analyze log-level debug"
right before the hibernation attempt, and then the journal output
generated that way.

> Also, I'm not really sure whether the above is the most systemdic
> way... like should I use something like BindsTo= instead of RequiredBy=
> + StopWhenUnneeded=true?

Nah, sounds Ok to me.

> Also would it be better to explicitly set DefaultDependencies=no?

Probably, yeah, given that systemd-hibernate.service has that set too.

> 2) The whole thing seems to not work with auto-detection from desktop
> environments.
> I use Cinnamon, when clicking the shutdown icon, it shows me Suspend,
> Restart, Cancel, Shotdown.
>
> At least the Suspend seems to be somehow detected via systemd, cause
> when I set AllowSuspend=false in sleep.conf, it disappears.
>
> So I guess systemd thinks hibernation isn't possible, because there's
> now swap active, and tell that to the GUI.
> Guess I'd need some override, for that.

Yes, logind reports that hibernation is not supported if you have no
swap. Desktops ask logind for that.

Frnakly, the idea that we mount a swap partition only for hibernation
appears to be a bad idea to me. We should drop it from the TODO
list. If a swap partition is good for hibernation it is also good for
proper swap operation, and not using it for that makes things worth in
almost all ways.

Lennart

--
Lennart Poettering, Berlin



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux