Skip to content

Preflight the ESP free space before an update - #13462

Closed
AnPod wants to merge 3 commits into
omacom:quattrofrom
AnPod:fix/esp-free-space-preflight
Closed

AnPod wants to merge 3 commits into
omacom:quattrofrom
AnPod:fix/esp-free-space-preflight

Conversation

@AnPod

@AnPod AnPod commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Summary

omarchy-update-requires-free-space checked only /. On a UKI + Limine install the ESP is the actual constrained resource: a kernel update writes a fresh UKI while limine-snapper-sync still holds its retained copies, and an ESP that fills mid-update leaves the machine unbootable while root happily reports terabytes free (#13355).

The preflight now additionally guards the ESP when it is a separate filesystem:

  • Resolves the ESP from ESP_PATH in /etc/default/limine (repo convention from omarchy-provision-owner), defaulting to /boot.
  • Skips when the ESP lives on the root filesystem (the existing 10 GiB check already covers it) or when there is no UKI to size against.
  • Requires free space of at least 2× the largest .efi already on the ESP — room for the new UKI plus the retention churn around it — and refuses with a message naming the ESP path and the human-sized shortfall.
  • An unmeasurable ESP warns on stderr rather than blocking the update.

Fixes #13355

Testing

  • test/shell.d/update-disk-space-test.sh extended with stubbed sed/findmnt/df and a fake 300 MiB UKI: full ESP blocks and names the path; exactly 2× largest UKI proceeds; shortfall scales with the UKI on disk (no fixed floor); no UKIs skips; root-backed ESP defers to the root check. 12/12 assertions pass.

@jandrusk

jandrusk commented Oct 7, 2026

Copy link
Copy Markdown

Thanks for picking up #13355. Checking the ESP is the right idea. I read the diff against current quattro and have a few notes before this is ready:

  1. The "ESP lives on root" check misses the case it's meant for. findmnt -nro SOURCE "$esp" only matches mountpoints. When /boot is a plain directory on root, it prints nothing and exits 1, so the comparison fails and the script goes on to find/df against root. The result is still correct (df reports root's free space), but the skip never fires. -T resolves the filesystem that contains the path:
    if [[ $(findmnt -nro SOURCE -T "$esp" 2>/dev/null) == "$(findmnt -nro SOURCE -T / 2>/dev/null)" ]]; then
  2. Permissions on the ESP. This runs as the user, before omarchy-update asks for sudo. If the ESP is mounted root-only (fmask=0077,dmask=0077, which Arch recommends since systemd's random-seed warning), find sees no .efi files and the check quietly skips. Could you check what mount options the Omarchy installer uses for /boot? If it can be root-only, either read the sizes another way or print a warning when the ESP can't be read, so it doesn't pass silently.
  3. Headroom. The reporter's machine in omarchy-update-requires-free-space checks only /, never the ESP — a full /boot breaks booting with no warning #13355 had 933M free and a 280M UKI, so it passes a 2x check, but it still ran out once limine-snapper-sync copied history UKIs. Sizing against the number of installed kernels plus one (e.g. pacman -Qq linux linux-omarchy 2>/dev/null | wc -l), as the issue suggested, would be safer than a flat 2x.

Also, #13602 (yours too, now conflicting) uses a different rule (largest UKI or a 400 MiB floor). It's probably worth closing that one so only one approach is up for review.

AnPod and others added 3 commits October 9, 2026 07:46
The update preflight only checked /, so a UKI + Limine install could fill
its small ESP mid-update and leave the machine unbootable while root
still reported 10 GiB free. Size the ESP ask against the largest UKI
already on disk (room for one more plus retention churn) and name the
ESP path in the refusal.

Fixes omacom#13355
- Compare filesystems with findmnt -T, so the skip also fires when /boot
  is a plain directory on root.
- Warn instead of passing silently when the UKIs on the ESP can't be
  listed (e.g. a root-only fmask/dmask mount).
- Size the headroom by installed kernels plus one (at least two copies)
  instead of a flat 2x, since limine-snapper-sync also keeps history UKIs.
@AnPod
AnPod force-pushed the fix/esp-free-space-preflight branch from 5d4b997 to 45a7879 Compare October 9, 2026 05:50
@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[High impact] Adds preflight check for boot partition space before system updates.

The PR appears safe to merge, with a non-blocking issue where unrelated bootloader files can cause updates to be refused.

Findings

  1. P2 Bootloader files block updates ▶

Summary

The PR adds an ESP space check before updates while keeping the existing root-space check.

  • Reads ESP_PATH, measures the largest .efi file, and adjusts the requirement for installed kernels.
  • Adds tests for space boundaries, kernel counts, and fallback behavior.
  • The scan needs to distinguish UKIs from other bootloader files.

Reviews (1) · Last reviewed commit: "Tighten the ESP free-space preflight" · Reviewed by Greptile

Comment on lines +33 to +35
# No UKIs (different bootloader, or a wiped ESP) means nothing to size against.
if uki_sizes=$(find "$esp" -xdev -type f -name '*.efi' -printf '%s\n' 2>/dev/null); then
largest_uki_bytes=$(sort -nr <<< "$uki_sizes" | head -n 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Bootloader files block updates

The scan treats every .efi file as a UKI. If the ESP has another bootloader but no UKIs, files such as BOOTX64.EFI still produce a space requirement. The check can then refuse an update instead of taking the documented no-UKI skip. Limit the scan to UKI files and add a test with a bootloader file but no UKIs.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 45a7879. The problem in #13355 is real, but on a stock install this change does not stop the update it is meant to stop.

What was checked. I ran it on a worker VM installed from the current Omarchy ISO. There /boot is vfat mounted fmask=0077,dmask=0077, so the directory is drwx------ root. omarchy-update calls omarchy-update-requires-free-space as the desktop user at bin/omarchy-update:99, before it asks for sudo, so the find "$esp" at bin/omarchy-update-requires-free-space:34 is refused. The script then takes the warning branch and exits 0. With the worker's ESP filled to 60M free (one 41.6M UKI, linux-omarchy installed):

  • quattro, as the user: exit 0
  • this head, as the user: exit 0, plus "Could not scan UKIs in /boot; permissions may prevent verifying UKI headroom"
  • this head, as root: exit 1, "You need at least 80M free in /boot to safely update Omarchy."

So the sizing logic works when it can read the ESP, but the real call path never lets it, and every update on a stock install prints the warning. test/shell.d/update-disk-space-test.sh passes on the worker (18 passed), but it builds a readable ESP in a temp directory, so it cannot catch this. The unreadable-ESP case is asserted as warn-and-continue.

What needs deciding. How the check gets to read the ESP is a design call, not a contained fix, so I have pushed nothing. One option is running it after authorize_update and reading sizes through sudo. Another is falling back to a fixed floor when the ESP cannot be listed. Two smaller points to weigh at the same time:

  • Even with read access, the reporter's numbers pass: 280M UKI × (2 kernels + 1) = 840M, against 933M free. Kernels + 1 does not account for the limine_history copies limine-snapper-sync makes, which is what filled their ESP.
  • The kernel list at lines 51–57 has no linux-hardened.

The Greptile note about *.efi matching non-UKI files does not change the result on a stock ESP: limine_x64.efi is 372K and the UKI is the largest file.

Competing fixes. #12246 is older but bundles five unrelated changes, conflicts with quattro, and its ESP check is a fixed 300 MiB, below a single UKI on the reporter's machine. #13602 is newer and conflicting, and also exits 0 when the ESP cannot be read. This one is the one to carry forward.

Second opinion. Codex Medium reviewed the same diff, given the worker's mount measurements. It reached the same conclusion on the unreadable ESP and the reporter's numbers, though that agreement is not independent: it was handed the measurements and can read this session. The linux-hardened gap was its finding. It also suggested a failed findmnt could skip the check, which I set aside because findmnt -T / does not fail on a running system.

Waiting on the author to choose how the check reads the ESP under the real caller.

AnPod commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of my other PR #13602, which covers the same issue (#13355).

@AnPod AnPod closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy-update-requires-free-space checks only /, never the ESP — a full /boot breaks booting with no warning

3 participants