I have set up a nightly hibernation routine (see below) but it
sometimes works and sometimes doesn't. It appears to be completely
random.

When I invoke it manually, via 'systemctl hibernate' it invariably
works.

   $ systemctl status hibernate-preparation hibernate-resume
   ○ hibernate-preparation.service - Enable swap file and disable zram before 
hibernate
        Loaded: loaded (/etc/systemd/system/hibernate-preparation.service; 
enabled; preset: disabled)
       Drop-In: /usr/lib/systemd/system/service.d
                └─10-timeout-abort.conf
        Active: inactive (dead)
   
   ○ hibernate-resume.service - Disable swap after resuming from hibernation
        Loaded: loaded (/etc/systemd/system/hibernate-resume.service; enabled; 
preset: disabled)
       Drop-In: /usr/lib/systemd/system/service.d
                └─10-timeout-abort.conf
        Active: inactive (dead)
   
   $ cat hibernate-preparation.service
   [Unit]
   Description=Enable swap file and disable zram before hibernate
   Before=systemd-hibernate.service
   
   [Service]
   User=root
   Type=oneshot
   ExecStart=/bin/bash -c /usr/sbin/swapon /SWAP/swapfile && /usr/sbin/swapoff 
/dev/zram0
   
   [Install]
   WantedBy=systemd-hibernate.service
   
   $ cat hibernate-resume.service
   [Unit]
   Description=Disable swap after resuming from hibernation
   After=hibernate.target
   
   [Service]
   User=root
   Type=oneshot
   ExecStart=/usr/sbin/swapoff /SWAP/swapfile
   
   [Install]
   WantedBy=hibernate.target
   
When it fails, I get this in the journal:

   Aug 13 01:05:25 Bree systemd[1]: Reached target sleep.target - Sleep.
   Aug 13 01:05:25 Bree systemd[1]: Starting hibernate-preparation.service - 
Enable swap file and disable zram before hibernate...
   Aug 13 01:05:25 Bree bash[118343]: NAME       TYPE      SIZE USED PRIO
   Aug 13 01:05:25 Bree bash[118343]: /dev/zram0 partition   8G 1.6G  100
   Aug 13 01:05:25 Bree systemd[1]: hibernate-preparation.service: Deactivated 
successfully.
   Aug 13 01:05:25 Bree systemd[1]: Finished hibernate-preparation.service - 
Enable swap file and disable zram before hibernate.
   Aug 13 01:05:25 Bree systemd[1]: Starting systemd-hibernate.service - 
Hibernate...
   Aug 13 01:05:25 Bree systemd-sleep[118344]: Failed to find location to 
hibernate to: Function not implemented
   Aug 13 01:05:25 Bree systemd[1]: systemd-hibernate.service: Main process 
exited, code=exited, status=1/FAILURE
   Aug 13 01:05:25 Bree systemd[1]: systemd-hibernate.service: Failed with 
result 'exit-code'.
   Aug 13 01:05:25 Bree systemd[1]: Failed to start systemd-hibernate.service - 
Hibernate.
   Aug 13 01:05:25 Bree systemd[1]: Dependency failed for hibernate.target - 
System Hibernation.
   Aug 13 01:05:25 Bree systemd[1]: hibernate.target: Job 
hibernate.target/start failed with result 'dependency'.
   Aug 13 01:05:25 Bree systemd-logind[948]: Operation 'sleep' finished.
   Aug 13 01:05:25 Bree systemd[1]: Stopped target sleep.target - Sleep.
   Aug 13 01:05:25 Bree ModemManager[1029]: <info>  [sleep-monitor-systemd] 
system is resuming
   
When it succeeds, I get this:

   Aug 13 17:23:24 Bree systemd[1]: Reached target sleep.target - Sleep.
   Aug 13 17:23:24 Bree systemd[1]: Starting hibernate-preparation.service - 
Enable swap file and disable zram before hibernate...
   Aug 13 17:23:24 Bree bash[40863]: NAME           TYPE      SIZE USED PRIO
   Aug 13 17:23:24 Bree bash[40863]: /SWAP/swapfile file       32G   0B   -2
   Aug 13 17:23:24 Bree bash[40863]: /dev/zram0     partition   8G   0B  100
   Aug 13 17:23:24 Bree systemd[1]: hibernate-preparation.service: Deactivated 
successfully.
   Aug 13 17:23:24 Bree systemd[1]: Finished hibernate-preparation.service - 
Enable swap file and disable zram before hibernate.
   Aug 13 17:23:24 Bree systemd[1]: Starting systemd-hibernate.service - 
Hibernate...
   Aug 13 17:23:24 Bree plasmashell[2504]: qt.qpa.clipboard: 
QXcbClipboard::setMimeData: Cannot set X11 selection owner
   Aug 13 17:23:24 Bree systemd[1]: httpd.service: Sent signal SIGWINCH to main 
process 1116 (httpd) on client request.
   Aug 13 17:23:24 Bree systemd-sleep[40865]: Entering sleep state 
'hibernate'...
   
The difference is that in the failure case it's not seeing the swap
file, but that file always exists and has the correct permissions:

   # ls -lhZ /SWAP/swapfile 
   -rw-------. 1 root root unconfined_u:object_r:swapfile_t:s0 32G Jul 12 12:46 
/SWAP/swapfile
   # df -h /SWAP
   Filesystem      Size  Used Avail Use% Mounted on
   -               1.9T  1.6T  246G  87% /SWAP
   [root@Bree log]# file /SWAP
   /SWAP: directory
   
(/SWAP is a BTRFS subvolume with COW turned off)
   
I'm at a loss. Any thoughts?

poc
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to