diff --git a/man/rules/meson.build b/man/rules/meson.build index e483196c5c5d0..7b89afef9578b 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -944,7 +944,7 @@ manpages = [ ['systemd-hibernate-resume-generator', '8', [], 'ENABLE_HIBERNATE'], ['systemd-hibernate-resume.service', '8', - ['systemd-hibernate-resume'], + ['systemd-hibernate-resume', 'systemd-hibernate-resume-clear-efi.service'], 'ENABLE_HIBERNATE'], ['systemd-homed.service', '8', ['systemd-homed'], 'ENABLE_HOMED'], ['systemd-hostnamed.service', '8', ['systemd-hostnamed'], 'ENABLE_HOSTNAMED'], diff --git a/man/systemd-hibernate-resume.service.xml b/man/systemd-hibernate-resume.service.xml index f6cdefdd3a0fb..c64901461d544 100644 --- a/man/systemd-hibernate-resume.service.xml +++ b/man/systemd-hibernate-resume.service.xml @@ -17,12 +17,14 @@ systemd-hibernate-resume.service + systemd-hibernate-resume-clear-efi.service systemd-hibernate-resume Resume from hibernation systemd-hibernate-resume.service + systemd-hibernate-resume-clear-efi.service /usr/lib/systemd/systemd-hibernate-resume @@ -37,6 +39,12 @@ /sys/power/resume, along with the offset in memory pages (/sys/power/resume_offset) if supported. + The resume device node is either passed directly through arguments, or automatically acquired + from kernel command line options and/or HibernateLocation EFI variable. The latter + will normally be cleared by systemd-hibernate-resume.service on resumption. + If a stale variable is detected, it would be cleared by + systemd-hibernate-resume-clear-efi.service. + Failing to initiate a resume is not an error condition. It may mean that there was no resume image (e. g. if the system has been simply powered off and not hibernated). In such cases, the boot is ordinarily continued. diff --git a/units/meson.build b/units/meson.build index 6fecbea0a1b52..6145d45df8cbc 100644 --- a/units/meson.build +++ b/units/meson.build @@ -316,6 +316,11 @@ units = [ 'file' : 'systemd-hibernate-resume.service.in', 'conditions' : ['ENABLE_HIBERNATE'], }, + { + 'file' : 'systemd-hibernate-resume-clear-efi.service.in', + 'conditions' : ['ENABLE_HIBERNATE', 'ENABLE_EFI'], + 'symlinks' : ['sysinit.target.wants/'], + }, { 'file' : 'systemd-hibernate.service.in', 'conditions' : ['ENABLE_HIBERNATE'], diff --git a/units/systemd-hibernate-resume-clear-efi.service.in b/units/systemd-hibernate-resume-clear-efi.service.in new file mode 100644 index 0000000000000..6805c8cdd6281 --- /dev/null +++ b/units/systemd-hibernate-resume-clear-efi.service.in @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Clear Stale Hibernate EFI Variable +Documentation=man:systemd-hibernate-resume-clear-efi.service(8) + +ConditionPathExists=/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67 +ConditionPathExists=!/etc/initrd-release + +DefaultDependencies=no +Before=sysinit.target shutdown.target +Conflicts=shutdown.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart={{LIBEXECDIR}}/systemd-hibernate-resume --clear-efi