Hey. On Wed, 2023-03-29 at 10:20 +0200, Lennart Poettering wrote: > > 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. Well I haven't said it's bad, but I guess it depends on the use case any available RAM. If one has plenty of the latter (e.g. our servers at the university have all at least 64GB or more - and even my laptop has) what else than giving you a bit more extra on top does swap give you? At the potential cost of the system going into trashing instead, making it more or less completely unresponsive. If your memory is limited, like perhaps on IoT, and you rarely (say once a day when some extra cron jobs run) need more than physical memory is available, then sure... in that case it's good to have some relieve of memory pressure. But if one generally uses more than one has, I feel it would be better to run into the oom killer soon. And even if one's scared about some precious process being killed in a short period of memory pressure... the swap may possibly just shift that to some later time. I've looked a bit around at any recommendations, but I couldn't really find much credible sources. It rather seemed thought that the older some post/blog/etc. is the more likely they recommend swap and the more recent they rather recommend little to none. And even if it was still generally recommended/useful, looking at the comments people give (or there was e.g. that survey [0]) there still simply seems to be quite some fraction of people who wants to run without. The aforementioned patchset also seems like a good indicator that there is some desire to use swap for hibernate only. And even if you argue that people should have swap, there might still be valid use cases for enabling certain swap partitions only for hibernate. E.g. people might want to use https://ddramdisk.store/ (which is however volatile) for swapping, but another swap on persistent storage for hibernate (only). Or one could want to use such a volatile device as "normal" swap without encryption, and an extra one for hibernation with encryption. > > > > 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. Uhm... sorry, I don't quite get hat: systemd-analyze log-level debug doesn't seem to be a valid command? Or do you mean something like: export SYSTEMD_LOG_LEVEL=debug systemd-analyze dump but that doesn't contain anything about "*hibernate*". Neither does it generate any output in journalctl -f or with _SYSTEMD_UNIT=systemd-hibernate.service or _SYSTEMD_UNIT=hibernate.target > > > > 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. Thanks. > > > > Also would it be better to explicitly set > > > > DefaultDependencies=no? > > > > Probably, yeah, given that systemd-hibernate.service has that set > > too. But that would also mean that when the swap was enabled manually (and not via the RequiredBy=systemd-hibernate.service) it wouldn't get stopped on umount.target? > > > 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. So I guess that since you're anyway rather against running without swap you probably wouldn't accept a feature request that asks for some method to override that auto-detection (something like AdvertiseHibernate=(auto|always|never) )? Cheers, Chris. [0] https://opensource.com/article/19/2/swap-space-poll