Skip to content

Name the hibernation resume device by its filesystem UUID - #16658

Merged
emirb merged 6 commits into
quattrofrom
hibernation/resume-by-uuid
Oct 25, 2026
Merged

emirb merged 6 commits into
quattrofrom
hibernation/resume-by-uuid

Conversation

@emirb

@emirb emirb commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Hibernation setup writes resume= from findmnt's SOURCE column. On an unencrypted install that is the partition's kernel name (resume=/dev/nvme0n1p2). NVMe names follow the order the controllers finish probing, so on a machine with two NVMe disks they can swap between boots, and then:

  • the hibernated session is lost: the initramfs looks for the image on the other disk and cold-boots;
  • or, on a boot where the names have moved, Hibernate is refused outright: Call to Hibernate failed: Specified resume device is missing or is not an active swap device.

Encrypted installs get /dev/mapper/root, which is stable, so this hits unencrypted installs on machines with more than one NVMe disk, whichever installer made them. It was found on an MSI desktop with two NVMe disks, where the install's root came up as nvme0n1p4 while resume= named nvme1n1p4, an ext4 partition on the other disk.

This writes resume=UUID=<filesystem UUID> instead, keeping /dev/mapper/* names as they are:

  • mkinitcpio's resume hook hands off to systemd-hibernate-resume on systemd 255 and later, which resolves resume= with fstab_node_to_udev_node() to /dev/disk/by-uuid/; the hook's own resolve_device() handles UUID= on older systemd, and the udev hook ships 60-persistent-storage.rules, so the link exists in the initramfs.
  • systemd's HibernateLocation EFI variable already names the device by /dev/disk/by-uuid/, but resume= on the command line wins over it, which is why a stale kernel name loses the session even though that variable names the right disk.

Machines set up before keep their kernel name until something rewrites it, so a rerun of hibernation setup on a configured machine now renames the device in the line setup itself writes (current and 3.4 forms), and rebuilds the boot image. A marker in /var/lib/omarchy, written before the drop-in changes, stays until a rebuild succeeds, so a rebuild that fails, that limine-mkinitcpio reports as skipped while still exiting 0 (as migration 1791621765 already handles), or that is cut off by closing the update terminal is done again on the next run. A migration runs setup on machines whose drop-in names a kernel device or that still have the marker, and whose resume hook is in place; a failed rebuild leaves it pending. Hand-edited drop-ins, encrypted installs and drop-ins already naming a UUID are left alone. The factory reset deletes the drop-in and reruns setup in the factory root, which now writes the UUID.

What the initramfs logs on a two-NVMe machine when the other disk probes first, before:

nvme nvme0: pci function 0000:01:00.0        <- the second disk
nvme nvme1: pci function 0000:02:00.0        <- the Omarchy disk
resume=/dev/nvme0n1p2 doesn't match with EFI HibernateLocation device '/dev/disk/by-uuid/973278e9-…', proceeding anyway with resume=.
Unable to resume from device '/dev/nvme0n1p2' (259:2) offset 1515398, continuing boot process.

and after, with resume=UUID=973278e9-… and the same probe order, the session comes back:

nvme nvme0: pci function 0000:01:00.0        <- the second disk
nvme nvme1: pci function 0000:02:00.0        <- the Omarchy disk
PM: Image signature found, resuming
PM: hibernation: hibernation exit

#11477 reconciles the drop-in from findmnt -no SOURCE on every rerun, so whichever of the two lands second should take the device from resume_device here; otherwise a rerun would put the kernel name back. The UUID form was first suggested in a comment on #1417.

emirb added 3 commits October 25, 2026 23:08
Hibernation setup wrote resume= from findmnt's SOURCE column. On an
unencrypted install that is the partition's kernel name, such as
/dev/nvme1n1p4. NVMe names follow the order the controllers finish
probing, so on a machine with two NVMe disks they can swap between
boots: resume= then names a partition on the other disk, the initramfs
finds no hibernation image there, and the machine cold-boots with the
session lost. On an MSI desktop with two NVMe disks the install's root
came up as nvme0n1p4 while resume= named nvme1n1p4, an ext4 partition
on the other disk.

Write resume=UUID=<filesystem UUID> instead. Both resume paths accept
it: mkinitcpio's resume hook hands off to systemd-hibernate-resume on
systemd 255 and later, which resolves resume= with
fstab_node_to_udev_node() to /dev/disk/by-uuid/, and the hook's own
resolve_device() handles UUID= on older systemd. The udev hook ships
60-persistent-storage.rules, so the link exists in the initramfs. The
kernel's early lookup rejects UUID= and leaves resume to the initramfs,
which is where it runs on these installs anyway, since nvme is a
module there.

A device-mapper name such as /dev/mapper/root on an encrypted install
is chosen by whoever opened the device and does not move, so it stays
as it is. If findmnt reports no UUID, setup falls back to the kernel
name it wrote before.
A machine set up before keeps resume=/dev/nvme0n1p2 in its drop-in,
and setup stopped at "Hibernation is already set up" without looking
at it. Now a rerun on a configured machine rewrites the line setup
itself writes, in the current and the Omarchy 3.4 form, with the
filesystem UUID and rebuilds the boot image. Device-mapper names, a
drop-in already naming a UUID and a drop-in edited by hand are left
alone, so a second run changes nothing.

limine-mkinitcpio 1.40 reports "mkinitcpio failed for kernel ...,
skipping." and still exits 0, so setup treats that line as a failed
rebuild, as migration 1791621765 does. On a failed rebuild the old line
goes back, so the drop-in matches the boot image and the next run tries
again. Both lines are written through install_root_file, the staged,
atomic replace the script already uses for its sleep hook, and are
staged before the drop-in changes, so a full disk cannot leave it
half-written. --no-rebuild leaves the rebuild to the caller, as the
installer and the factory reset expect.
Every unencrypted install so far carries a kernel name in
/etc/limine-entry-tool.d/resume.conf, and nothing reruns hibernation
setup on its own, so the previous change would only reach new installs
and factory resets. The migration runs setup on machines whose drop-in
names a /dev/ path outside /dev/mapper and whose resume hook is in
place; setup renames the device and rebuilds the boot image.

Machines without that drop-in, encrypted installs, and drop-ins already
naming a UUID are skipped. If the boot image is not rebuilt, setup puts
the old drop-in back and exits 1, so the migration stays pending and
the next omarchy-migrate retries it.
@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain.

Summary

This PR names unencrypted resume devices by filesystem UUID while preserving /dev/mapper/* names.

  • Hibernation setup names plain resume devices by filesystem UUID.
  • Existing hibernation setups switch to UUIDs and rebuild their boot image.

The previous retry-loss finding is fixed. No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Run hibernation setup] --> B{Existing kernel-device line?}
  B -->|Yes| C[Write pending marker]
  C --> D[Replace device with UUID]
  B -->|No| E{Pending marker exists?}
  D --> E
  E -->|No| F[Finish]
  E -->|Yes| G[Rebuild boot image]
  G --> H{Rebuild succeeded?}
  H -->|Yes| I[Remove marker]
  I --> F
  H -->|No or interrupted| J[Keep marker for next run]
Loading

Reviews (3) · Last reviewed commit: "Retry a rebuild of the renamed resume de..." · Reviewed by Greptile

Comment thread bin/omarchy-hibernation-setup Resolved
Comment thread bin/omarchy-hibernation-setup Resolved
emirb added 3 commits October 26, 2026 00:06
A drop-in from a setup whose offset lookup failed reads
resume=/dev/nvme0n1p2 resume_offset= and does not match the line the
rename looks for, which needs a number there. The rename ran first and
skipped it, then the offset repair filled the offset in and rebuilt the
boot image with the kernel name still in it, and setup exited 0, so the
migration was marked done.

Run the rename after the offset repair, which leaves the device as it
found it. Such a drop-in now gets its offset, then the UUID, and the
boot image carries both.
The repository keeps a command's tests in its area's existing file, and
hibernation-setup-test.sh is that file. Its locale case still skips on
a machine without hibernation; the resume device cases redirect every
path they write and run anywhere. Trimmed to the cases that carry
logic: the UUID and device-mapper names on first setup, a rerun
renaming a kernel name once (with and without an empty offset), the
restore when a kernel's image is not rebuilt, and drop-ins setup does
not own.
When the boot image was not rebuilt after the rename, setup put the old
line back. That retry only held if the restore itself succeeded and the
run lived long enough to do it. Closing the update terminal while the
image builds kills setup in between: the drop-in already names the
UUID, the boot image still names the kernel device, and the next
omarchy-migrate saw a UUID, exited 0 and marked the migration done. In
a VM with the 4.5.0rc1 install, a SIGHUP to the migration's process
group a second into the build left exactly that, with
/boot/limine.conf still carrying resume=/dev/nvme0n1p2 for good.

Setup now writes /var/lib/omarchy/hibernation-resume-rebuild before it
touches the drop-in and removes it only after a rebuild that
limine-mkinitcpio did not report as skipped. While the marker exists,
setup rebuilds, and the migration runs setup again. A failed, skipped
or interrupted rebuild therefore leaves a state the next run finishes,
and the restore goes away. --no-rebuild callers rebuild themselves and
get no marker.
@emirb
emirb merged commit 6573c3d into quattro Oct 25, 2026
2 checks passed
omarchybot added a commit to yashranaway/omarchy that referenced this pull request Oct 31, 2026
quattro now renames a kernel-name resume device and rebuilds the boot image behind a pending marker (omacom#16658), in the same already-set-up block. --force and the offset repair rebuild only when that marker is not already doing it, so a run rebuilds once.

quattro's test runs the real command with its system paths rewritten into a scratch directory, so the OMARCHY_HIBERNATION_* path overrides this branch added for its tests are no longer needed and are dropped; the forced-rebuild cases move into that harness.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@emirb emirb added this to the 4.5 milestone Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant