Re: More hibernation mystery

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


On Sun, 13 Aug 2023 22:12:23 +0100 Patrick O'Callaghan wrote:

> On Sun, 2023-08-13 at 18:49 +0200, Francis.Montagnac@xxxxxxxx wrote:
>> ExecStart=/bin/bash -c '/usr/sbin/swapon /SWAP/swapfile && /usr/sbin/swapoff /dev/zram0'

> I'll do that, but I don't understand why it sometimes works and
> sometimes doesn't.

The journal when it succeeds shows that /SWAP/swapfile was activated. That may
be due to hibernate-resume.service previously failed or was not called.

In addition swapon fails when the swapfile is already activated. A better
hibernate-preparation.service would be:

  ExecStart=/bin/bash -c ' \
      if ! swapon --show=NAME --noheadings | grep -q /SWAP/swapfile; then \
          swapon /SWAP/swapfile || exit; \
      fi; \
      swapoff /dev/zram0; \
      # Ignores the exit code of swapoff.
      exit 0; \

To improve if needed to check also if /dev/zram0 is validated or not.

Note that systemd concatenates the lines ending with \ to a single line.
This make mandatory to end each bash commands, even the if, by ;

francis.montagnac@xxxxxxxx, DSI-SP, Tel: (33) 04 92 38 79 11, Bur: C111
INRIA Sophia, 2004, route des Lucioles - BP 93 06902 Sophia Antipolis Cedex
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct:
List Guidelines:
List Archives:
Do not reply to spam, report it:

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux