Skip to content

install: Only remove bootloader dirs from the ESP - #2475

Open
ericcurtin wants to merge 1 commit into
bootc-dev:mainfrom
ericcurtin:install-preserve-esp-content
Open

ericcurtin wants to merge 1 commit into
bootc-dev:mainfrom
ericcurtin:install-preserve-esp-content

Conversation

@ericcurtin

Copy link
Copy Markdown
Contributor

Problem

bootc install to-existing-root (alongside mode) empties the entire EFI System Partition in clean_boot_directories(). The ESP is frequently shared with content bootc does not manage and cannot recreate.

Concrete case: converting a Fedora Asahi Remix 43 install on an Apple Silicon Mac mini to quay.io/fedora-asahi-remix-atomic-desktops/base-atomic:44. The Asahi installer keeps on the ESP:

  • m1n1/boot.bin - stage 2 m1n1 + U-Boot, chainloaded by stage 1 from the Apple boot partition. Without it the machine cannot boot Linux at all.
  • vendorfw/ - Apple device firmware (WiFi, Bluetooth, ...) loaded by the Asahi dracut module at boot.
  • ubootefi.var - U-Boot's EFI variable store.
  • asahi/ - installer metadata.

After the install the ESP contained only EFI/. The system was only recoverable because a copy of the ESP had been made beforehand. The same class of problem applies to any platform that stores firmware or earlier boot stages on the ESP (U-Boot based SBCs, some Chromebooks, ...).

There is already a // TODO: we should also support not wiping the ESP. at that spot.

Change

  • Only remove the EFI/ and loader/ directories from the ESP. These are the trees written by bootupd (shim/grub) and systemd-boot, and they are reinstalled immediately afterwards. Everything else on the ESP is preserved.
  • Update the to-existing-root docs, which currently state that /boot/efi "will be reinitialized".
  • Add a unit test (test_clean_esp_bootloader_dirs) covering removed vs. preserved content and idempotency.

Testing

  • cargo test -p bootc-lib --lib install::tests::test_clean_esp_bootloader_dirs install::tests::test_remove_all_noxdev passes (Fedora 44, aarch64).
  • cargo fmt --check clean.
  • The real-world install above was completed by manually restoring the wiped ESP content from a backup before reboot; with this change that step would not have been necessary.

AI disclosure

Generated-by: AI

Per AGENTS.md, the commit intentionally carries no Signed-off-by; the human submitter will review and add it. The problem was diagnosed and reproduced on real hardware by the submitter; the code change and unit test are LLM generated and were compiled and tested as described above.

In alongside mode (`install to-existing-root`) we currently empty the
whole EFI System Partition. However the ESP is frequently shared with
content bootc does not manage and cannot recreate. On Apple Silicon the
Asahi installer places the stage 2 bootloader (m1n1/boot.bin, which
stage 1 chainloads), the device firmware payload (vendorfw/) and the
U-Boot EFI variable store (ubootefi.var) on the ESP. Wiping them leaves
the machine unable to boot Linux at all and without WiFi/Bluetooth
firmware; this was hit while converting a Fedora Asahi Remix install to
a bootc image.

Only remove the EFI/ and loader/ directories, which are the trees
written by bootupd (grub/shim) and systemd-boot and which we are about
to reinstall anyway, and preserve everything else. This also resolves
the existing TODO about not wiping the ESP.

Update the to-existing-root documentation accordingly and add a unit
test covering the preserved content.

Generated-by: AI
@ericcurtin

ericcurtin commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

This seems like a safer default than what was suggested in the TODO @cgwalters "TODO: we should also support not wiping the ESP."

Disclosure: very much not AI writing this comment :)

Comment thread crates/lib/src/install.rs
/// the device firmware payload (`vendorfw/`) and the U-Boot EFI variable store
/// (`ubootefi.var`) on the ESP; wiping them leaves the machine unbootable.
#[context("Removing bootloader content from EFI system partition")]
fn clean_esp_bootloader_dirs(efidir: &Dir) -> Result<()> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

People might also have custom bootloader config files in ESP/loader. I think we should read the config files and only remove the ones we own and the boot binaries referenced by them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe but I wouldn't mind a second opinion on that... For example... Would the pre-existing boot entries be completely broken after this? I'm open to it, but a second opinion could be interesting

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's more or less related to #2243. I don't think it's a blocker per se, but if we're going the distance to do this, then maybe we should just handle all the cases.

Would the pre-existing boot entries be completely broken after this?

we're deleting the pre-existing boot entries... so, yes.

@ericcurtin ericcurtin Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, maybe I didn't explain myself well enough... Even if we left the pre-bootc boot entries around... Would they even boot at that point? Would they even be useful after the conversion to a bootc system? (genuine question, haven't checked how destructive "bootc install to-existing-root" is to userspace, initramfs, kernel, etc. This is useful in Asahi because of the files required above needed to boot, not because of rollback to pre-bootc case)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Updates to the documentation area/install Issues related to `bootc install`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants