systemd
systemd copied to clipboard
systemd-hibernate-resume breaks the HibernateLocation EFI variable
systemd version the issue has been seen with
256.4
Used distribution
NixOS 24.11
Linux kernel version used
6.10.7
CPU architectures issue was seen on
x86_64
Component
other
Expected behaviour you didn't see
/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67 does not exist after resume from hibernate (or at least works if it does exist).
Unexpected behaviour you saw
/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67 exists, but is broken (reading gives nothing (not even the usual header), deletion fails with input/output error). The reason appears to be that systemd-hibernate-resume deletes this variable while the kernel is still hibernated, so after resume efivarfs thinks the variable is still there but it actually isn't.
Steps to reproduce the problem
- Hibernate system
- Resume system
- Observe the file
/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67exists - Try to delete it (for example using
systemctl start systemd-hibernate-clear.service, or usingchattrandrm)
Additional program output to the terminal or log subsystem illustrating the issue
No response
Hmm, I'm quite sure this should be considered a kernel bug. Boot loaders might change/remove efivars before hibernation takes place, hence this is not a systemd-hibernate-resume specific thing.
I am also having this issue on NixOS
Same issue on NixOS Seems like everyone else's also having it on that distro, could this be an upstream issue?
I guess NixOS users are just particularly prone to attempting to restart that unit, as switching configuration does.
Hmm, I'm quite sure this should be considered a kernel bug
This is intended behavior. Looking at https://github.com/torvalds/linux/blob/c2ee9f594da826bea183ed14f2cc029c719bf4da/fs/efivarfs/file.c#L81-L88 reveals that empty files represent uncommitted EFI vars. The code that causes the error here is this: https://github.com/systemd/systemd/blob/b6b8527cd184085008585c1a1f9725eb97c342ef/src/basic/efivars.c#L99-L101
perhaps the service should check for this then?
I create a PR to fix that, introduce the PR into my nixos config fix the problem. Maybe you can try the PR if you are on nixos.
https://github.com/systemd/systemd/pull/35497
Is there any way to get around this problem if it occurs in NixOS, e.g. after a hibernation and one runs nixos-rebuild switch?
Is there any way to get around this problem if it occurs in NixOS, e.g. after a hibernation and one runs
nixos-rebuild switch?
@Granddave Apply my patch. After that, you need to reboot your nixos to ensure overrided systemd package is used.
{ config, lib, pkgs, ... }:
{ systemd.package = pkgs.systemd.overrideAttrs (old: {
patches = old.patches ++ [
(pkgs.fetchurl {
url = "https://github.com/wrvsrx/systemd/compare/tag_fix-hibernate-resume%5E...tag_fix-hibernate-resume.patch";
hash = "sha256-iDC5lenk4LhDdU4ZRHjestYu2jXNvNZCgSCkE2hQHuQ=";
})
];
}) };