omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Laptops don't hibernate on critical battery: UPower's default `Auto` resolves to suspend-then-hibernate at 2 %, and the battery can die first

Open technobenja opened this issue 2 months ago • 3 comments

System details

  • Omarchy 4.0.4-1, systemd 261.2-1, upower 1.91.3-1, kernel 7.2.5-3-omarchy
  • MacBook Pro 11,1 (13-inch Retina, Mid 2014), Intel-only, new battery (health ~105 %)
  • Hibernation set up by Omarchy (omarchy-hibernation-setup: swapfile, resume hook, resume=/resume_offset=); omarchy-hibernation-available → 0; logind CanHibernate = yes
  • omarchy-debug --print --no-sudo: the SYSTEM INFORMATION section is below. I left out the journal section, which is mostly firewall log lines about my own LAN.

What's wrong?

Omarchy sets up hibernation, but nothing uses it to protect the machine when the battery runs out. On a deliberate full drain the laptop ran to empty and powered off hard at 2 %. The next boot showed a dirty-bit fsck on the ESP and systemd-journald reported the previous boot was "uncleanly shut down"; the last ~30 s of the journal were lost. No hibernate image was written: systemd-hibernate-clear.service was skipped on that boot because the HibernateLocation EFI variable was absent.

What the stock configuration resolves to (measured, read-only):

$ grep -E '^(PercentageLow|PercentageCritical|PercentageAction|CriticalPowerAction)' /etc/UPower/UPower.conf
PercentageLow=20.0
PercentageCritical=5.0
PercentageAction=2.0
CriticalPowerAction=Auto
$ busctl call org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower GetCriticalAction
s "Sleep"
$ busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager SleepOperation
as 3 "suspend-then-hibernate" "suspend" "hibernate"

So Auto resolves to logind's Sleep(), which is suspend-then-hibernate, and it fires at 2 %. On this machine, and on this battery's final percent, there was not enough left.

Why the threshold and the action must change together. Raising PercentageAction on its own makes things worse: with Auto the machine would first suspend to RAM at the higher threshold, and then rely on a rate-estimated wake to hibernate. Draining in S3 is the failure you are trying to prevent. The action has to be Hibernate itself.

What fixed it here (a drop-in, nothing package-owned edited):

# /etc/UPower/UPower.conf.d/70-critical-hibernate.conf
[UPower]
CriticalPowerAction=Hibernate
PercentageCritical=8.0
PercentageAction=5.0

After systemctl restart upower, GetCriticalAction → "Hibernate". Verified on a real battery drain: logind logged hibernate requested from client … ('upowerd') at UPower 4.81 %, the machine hibernated, and it resumed into the same boot (Waking up from system sleep state S4, HibernateLocation consumed), with the playing video paused where it stopped. Hibernating on battery under memory pressure took ≥ 110 s of snapshot work (the image write comes on top), versus ~17–22 s on AC, so 5 % leaves real margin where 2 % left none.

Suggestion. When omarchy-hibernation-setup enables hibernation on a machine with a battery, also install a UPower drop-in like the one above (action Hibernate, action threshold ~5 %, critical above it), and remove it in omarchy-hibernation-remove. It could be gated on omarchy-hibernation-available succeeding. I'd suggest proving a hibernate round-trip on AC before trusting it, since hibernate/resume varies by hardware; see #8352, #9237 and #12466.

Caveat worth knowing: UPower's percentage can be wrong. Here it once held an energy-full of 722.7 Wh on a 72.6 Wh battery (≈ 10× too large), so it reported ~3 % while the kernel said 33 %. systemctl restart upower cleared it. With CriticalPowerAction=Hibernate that would have hibernated a laptop at a real 33 %. It is safe, but surprising.

A worked, tested implementation (hibernate-test gate, the drop-in, a sysfs-based backstop in a monitor) is in omarchy-laptop-recovery.

omarchy-debug — SYSTEM INFORMATION (inxi -Farz)
Omarchy Package: omarchy 4.0.4-1
=========================================
SYSTEM INFORMATION
12System:
  12Kernel 7.2.5-3-omarchy 12arch x86_64 12bits 64 12compiler gcc 12v 16.2.1 12clocksource tsc 12avail acpi_pm
    12parameters cryptdevice=PARTUUID=<redacted>:root root=/dev/mapper/root
    zswap.enabled=0 rootflags=subvol=@ rw rootfstype=btrfs resume=/dev/mapper/root
    resume_offset=<n> initramfs_async=0 quiet splash loglevel=0 systemd.show_status=false
    rd.udev.log_level=0 vt.global_cursor_default=0
  12Desktop Hyprland 12v 0.56.2 12vt 1 12dm SDDM 12Distro Omarchy
12Machine:
  12Type Laptop 12System Apple 12product MacBookPro11,1 12v 1.0 12serial <superuser required> 12Chassis 12type 10
    12v Mac-189A3D4F975D5FFC 12serial <superuser required>
  12Mobo Apple 12model Mac-189A3D4F975D5FFC 12v MacBookPro11,1 12serial <superuser required>
    12uuid <superuser required> 12Firmware UEFI 12vendor Apple 12v 429.0.0.0.0 12date 12/02/2020
12Battery:
  12ID-1 BAT0 12charge 76.1 Wh (100%) 12condition 76.1/72.6 Wh (104.8%) 12temp 39.5 C 12volts 12.62 12min 11.34
    12model ifixit bq20z451 12type Li-ion 12serial N/A 12charging 12status full 12cycles 2
12CPU:
  12Info 12model Intel Core i5-4278U 12bits 64 12type MT MCP 12arch Haswell 12gen core 4 12level v3 12note check
    12built 2013-15 12process Intel 22nm 12family 6 12model-id 0x45 (69) 12stepping 1 12microcode 0x26
  12Topology 12cpus 1x 12dies 1 12clusters 2 12cores 2 12threads 4 12tpc 2 12smt enabled 12cache 12L1 128 KiB
    12desc d-2x32 KiB; i-2x32 KiB 12L2 512 KiB 12desc 2x256 KiB 12L3 3 MiB 12desc 1x3 MiB
  12Speed (MHz) 12avg 3100 12min/max 800/3100 12scaling 12driver intel_cpufreq 12governor schedutil 12cores
    121 3100 122 3100 123 3100 124 3100 12bogomips 20799
  12Flags-basic avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  12Vulnerabilities
  12Type gather_data_sampling 12status Not affected
  12Type ghostwrite 12status Not affected
  12Type indirect_target_selection 12status Not affected
  12Type itlb_multihit 12status KVM: Split huge pages
  12Type l1tf 12mitigation PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
  12Type mds 12mitigation Clear CPU buffers; SMT vulnerable
  12Type meltdown 12mitigation PTI
  12Type mmio_stale_data 12status Not affected
  12Type old_microcode 12status Not affected
  12Type reg_file_data_sampling 12status Not affected
  12Type retbleed 12status Not affected
  12Type spec_rstack_overflow 12status Not affected
  12Type spec_store_bypass 12mitigation Speculative Store Bypass disabled via prctl
  12Type spectre_v1 12mitigation usercopy/swapgs barriers and __user pointer sanitization
  12Type spectre_v2 12mitigation Retpolines; IBPB: conditional; IBRS_FW; STIBP: conditional; RSB
    filling; PBRSB-eIBRS: Not affected; BHI: Not affected
  12Type srbds 12mitigation Microcode
  12Type tsa 12status Not affected
  12Type tsx_async_abort 12status Not affected
  12Type vmscape 12mitigation IBPB before exit to userspace
12Graphics:
  12Device-1 Intel Haswell-ULT Integrated Graphics 12vendor Apple 12driver i915 12v kernel 12arch Gen-7.5
    12process Intel 22nm 12built 2013 12ports 12active eDP-1 12empty DP-1, DP-2, HDMI-A-1, HDMI-A-2
    12bus-ID 00:02.0 12chip-ID 8086:0a2e 12class-ID 0300
  12Display wayland 12server X.org 12v 1.21.1.24 12with Xwayland 12v 24.1.13 12compositor Hyprland 12v 0.56.2
    12driver 12gpu i915 12display-ID 1
  12Monitor-1 eDP-1 12model Apple Color LCD 12built 2012 12res 2560x1600 12dpi 227 12gamma 1.2
    12size 286x179mm (11.26x7.05") 12diag 337mm (13.3") 12ratio 16:10 12modes 2560x1600
  12API EGL 12Message EGL data requires eglinfo. Check --recommends.
  12Info 12Tools 12x11 xprop,xrandr
12Audio:
  12Device-1 Intel Haswell-ULT HD Audio 12vendor Apple 12driver snd_hda_intel 12v kernel 12bus-ID 00:03.0
    12chip-ID 8086:0a0c 12class-ID 0403
  12Device-2 Intel 8 Series HD Audio 12driver snd_hda_intel 12v kernel 12bus-ID 00:1b.0 12chip-ID 8086:9c20
    12class-ID 0403
  12Device-3 Broadcom 720p FaceTime HD Camera 12driver N/A 12pcie 12gen 2 12speed 5 GT/s 12lanes 1
    12bus-ID 02:00.0 12chip-ID 14e4:1570 12class-ID 0480
  12API ALSA 12v k7.2.5-3-omarchy 12status kernel-api 12tools alsactl,alsamixer,amixer
  12Server-1 sndiod 12v N/A 12status off 12tools aucat,midicat,sndioctl
  12Server-2 PipeWire 12v 1.6.8 12status active 12with 121 pipewire-pulse 12status active 122 wireplumber
    12status active 123 pipewire-alsa 12type plugin 124 pw-jack 12type plugin 12tools pactl,pw-cat,pw-cli,wpctl
12Network:
  12Device-1 Broadcom BCM4360 802.11ac Dual Band Wireless Network Adapter 12vendor Apple 12driver wl
    12v kernel 12modules bcma 12pcie 12gen 1 12speed 2.5 GT/s 12lanes 1 12bus-ID 03:00.0 12chip-ID 14e4:43a0
    12class-ID 0280
  12IF wlp3s0 12state up 12mac <filter>
  12Info 12services NetworkManager, systemd-timesyncd, wpa_supplicant
12Bluetooth:
  12Device-1 Apple Bluetooth USB Host Controller 12driver btusb 12v 0.8 12type USB 12rev 2.0 12speed 12 Mb/s
    12lanes 1 12mode 1.1 12bus-ID 1-3.3:6 12chip-ID 05ac:8289 12class-ID fe01
  12Report btmgmt 12ID hci0 12rfk-id 4 12state down 12bt-service enabled,running 12rfk-block 12hardware no
    12software yes 12address <filter> 12bt-v 4.0 12lmp-v 6 12status 12discoverable no 12pairing no
12Drives:
  12Local Storage 12total 113 GiB 12used 25.62 GiB (22.7%)
  12SMART Message Required tool smartctl not installed. Check --recommends
  12ID-1 /dev/sda 12maj-min 8:0 12vendor Apple 12model SSD SD0128F 12size 113 GiB 12block-size
    12physical 4096 B 12logical 512 B 12speed 6.0 Gb/s 12tech SSD 12serial <filter> 12fw-rev 321 12scheme GPT
12Partition:
  12ID-1 / 12raw-size 110.98 GiB 12size 110.98 GiB (100.00%) 12used 25.38 GiB (22.9%) 12fs btrfs
    12dev /dev/dm-0 12maj-min 253:0 12mapped root
  12ID-2 /boot 12raw-size 2 GiB 12size 2 GiB (99.80%) 12used 242.4 MiB (11.9%) 12fs vfat 12dev /dev/sda1
    12maj-min 8:1
  12ID-3 /home 12raw-size 110.98 GiB 12size 110.98 GiB (100.00%) 12used 25.38 GiB (22.9%) 12fs btrfs
    12dev /dev/dm-0 12maj-min 253:0 12mapped root
  12ID-4 /var/log 12raw-size 110.98 GiB 12size 110.98 GiB (100.00%) 12used 25.38 GiB (22.9%) 12fs btrfs
    12dev /dev/dm-0 12maj-min 253:0 12mapped root
12Swap:
  12Kernel 12swappiness 150 (default 60) 12cache-pressure 50 (default 100) 12zswap no
  12ID-1 swap-1 12type file 12size 7.66 GiB 12used 0 KiB (0.0%) 12priority 0 12file /swap/swapfile
  12ID-2 swap-2 12type zram 12size 7.66 GiB 12used 2.21 GiB (28.8%) 12priority 100 12comp zstd
    12avail lzo-rle,lzo,lz4,lz4hc,deflate,842 12dev /dev/zram0
12Sensors:
  12System Temperatures 12cpu 85.0 C 12mobo N/A
  12Fan Speeds (rpm) N/A
12Repos:
  12Packages 12pm pacman 12pkgs 1038 12libs 271 12tools yay
  12Active pacman repo servers in /etc/pacman.conf
    121 https: //pkgs.omarchy.org/stable/$arch
  12Active pacman repo servers in /etc/pacman.d/mirrorlist
    121 https: //stable-mirror.omarchy.org/$repo/os/$arch
12Info:
  12Memory 12total 8 GiB 12available 7.66 GiB 12used 5.28 GiB (69.0%)
  12Processes 269 12Power 12uptime 1d 20h 48m 12states freeze,mem,disk 12suspend deep 12avail s2idle
    12wakeups 2 12hibernate shutdown 12avail platform, reboot, suspend, test_resume 12image 2.92 GiB
    12services power-profiles-daemon, thermald, upowerd 12Init systemd 12v 261 12default graphical
    12tool systemctl
  12Compilers 12clang 22.1.8 12gcc 16.2.1 12Client shell wrapper 12v 5.3.15-release 12inxi 3.3.41

technobenja avatar Sep 25 '26 19:09 technobenja

Model-gating note from the 11,x hibernate trenches (https://github.com/omacom/omarchy/issues/11351): resume works on the Intel-only 11,1 (per https://github.com/omacom/omarchy/issues/10038) but hangs on 11,4 (Intel-only, blank after LUKS ~15%) and 11,5 (frozen lock screen, dead input, no journal) — dGPU exonerated as cause since the 11,4 has none.

So the reporter's fix (CriticalPowerAction=Hibernate at 5%) is safe on this 11,1 and does the right thing, but generalizing a Hibernate-on-critical path needs the same model gate as https://github.com/omacom/omarchy/pull/12125 (battery lid-close stays on plain suspend for MacBookPro11,x): on 11,4/11,5 a critical-battery hibernate writes an image that can never restore, converting a clean poweroff into a lost session. No drain test from this 11,5 (hibernation unusable here, drop-in reverted); analysis only.

rand0mdud3 avatar Oct 17 '26 23:10 rand0mdud3

Another way this ends in a dead battery, even with hibernation set up: the critical action fires only once, so a wake that ends the suspend-then-hibernate early leaves no protection. The next lid close is a plain suspend.

System: ThinkPad E14 Gen 7 (AMD Ryzen 7 250, s2idle only, no S3), Omarchy 4.5.0-3, upower 1.91.5, systemd 262.1, linux-omarchy 7.2.15-1. Hibernation was set up by the installer (omarchy-hibernation-available returns 0, CanHibernate is yes, SleepOperation is suspend-then-hibernate suspend hibernate), with stock CriticalPowerAction=Auto.

From journalctl and upower's charge history, 2026-11-27:

Time Battery Event
17:15:59 2% Lid opened, the machine wakes
17:16:20 2% suspend-then-hibernate requested from client PID 1402 ('upowerd') while the lid is still open
18:18:38 1% Lid closed wakes it: System returned from sleep operation 'suspend-then-hibernate'. No hibernate was attempted
18:19:05 1% logind's lid handling: Performing sleep operation 'suspend' (plain suspend)
18:51:38 0.5% Lid opened, the machine wakes
18:53:10 0.24% The journal stops with no shutdown: hard power loss

upower didn't request the critical action again after the 18:18 wake or the 18:51 wake, because the battery never left the action level. So everything after the first interrupted attempt was ordinary lid suspend.

For #13540: a direct Hibernate action avoids this, because it doesn't depend on the sleep running to completion. Laptops without hibernation keep Auto → Sleep() and are still exposed. A drop-in with CriticalPowerAction=PowerOff (GetCriticalAction → "PowerOff") is what I use here now.

luizfneves404 avatar Nov 28 '26 15:11 luizfneves404

A correction to my own comment here from October, because it argued for a model gate on a premise that no longer holds for this machine.

I wrote then that a Hibernate-on-critical path needs a MacBookPro11,x exemption because "on 11,5 a critical-battery hibernate writes an image that can never restore, converting a clean poweroff into a lost session". That was wrong, and it was wrong for a mundane reason: the machine had HOOKS+=(resume) with no resume.conf and no resume= on the cmdline (the state in https://github.com/omacom/omarchy/issues/7619), so it could not have hibernated whatever the policy was. With the parameters written, this 11,5 hibernates and restores on linux-omarchy 7.2.15-2 and 7.2.15-3 — eight cycles, session restored, keyboard and trackpad working afterwards. That correction and the measurement method are in https://github.com/omacom/omarchy/issues/11351#issuecomment-7232020712.

So the case for gating CriticalPowerAction=Hibernate on MacBookPro11,x should rest on the 11,4 report (https://github.com/omacom/omarchy/issues/11351#issuecomment-5905716801, hang before the display comes back) and not on this 11,5, which would be denied a working protection it can use. A model-wide MacBookPro11, gate is broader than the evidence.

That is separate from what @luizfneves404 reports, which is about the action firing only once rather than about which models can resume. The direct Hibernate action they suggest is the part this bears on: on this unit it does not need the sleep to run to completion to be effective, since the image does complete and restore.

Worth adding to their two data asks from upstream, if anyone here has the hardware: whether a second critical event after an interrupted suspend-then-hibernate re-fires at all (their journal suggests it does not, because the battery never rose above the action level).

rand0mdud3 avatar Nov 28 '26 19:11 rand0mdud3