Skip to content

Conversation

@mintsuki
Copy link
Contributor

Commit c095eb5 was supposed to introduce logic
such that if the grub-install command failed with a --removable flag, then
another attempt would be made with such flag removed.

This was broken because the --removable flag was kept in both cases (likely a
copy-paste mistake). This has been an issue since, in all future iterations of
the code.

What this commit does is fix this logic, but also invert the cases tested:
first test without --removable, then add it should that case fail, as this is
the most sensible thing to do.

@mintsuki mintsuki requested a review from Torxed as a code owner November 26, 2025 03:37
Commit c095eb5 was supposed to introduce logic
such that if the `grub-install` command failed with a `--removable` flag, then
another attempt would be made with such flag removed.

This was broken because the `--removable` flag was kept in both cases (likely a
copy-paste mistake). This has been an issue since, in all future iterations of
the code.

What this commit does is fix this logic, but also invert the cases tested:
first test without `--removable`, then add it should that case fail, as this is
the most sensible thing to do.
@mintsuki mintsuki force-pushed the fix-grub-removable-fallback branch from 003d525 to b5fc766 Compare November 26, 2025 03:38
@svartkanin
Copy link
Collaborator

This seems like a hack and a "lets try until it works" thing. I'd rather this to be an actual logic rather than abusive errors as if-else cases

@mintsuki
Copy link
Contributor Author

Well, I wouldn't necessarily call this a hack per se, and in any case the original logic was broken regardless.

I would also be okay with removing this fallback altogether and having users manually select the removable option from the menu (the one I added in a previous PR).

@h8d13
Copy link
Contributor

h8d13 commented Nov 26, 2025

Because --removable is always more reliable in both cases at least from personal experience

@mintsuki
Copy link
Contributor Author

mintsuki commented Nov 26, 2025

Because --removable is always more reliable in both cases at least from personal experience

Yes, but that is not a good argument for unconditionally using the --removable flag. If that was the intended usage of grub-install, it'd be the default.

The UEFI specification intends the removable path (on x86-64: /EFI/BOOT/BOOTX64.EFI) to only be used for, well, removable media, where the firmware cannot know ahead of time what the name of the EFI application to load is.

For non-removable media, the intended way is to let the firmware know what bootloaders/EFI applications are available with NVRAM entries (as managed by efibootmgr on Linux, for example).

Now, it is true that on some motherboards efibootmgr may fail, or NVRAM entries may be ignored, and on these motherboards, yes, one should use the removable location, short of other workarounds being available, but this shouldn't be what the installer defaults to. It should be a fallback.

The way Debian's installer sorts this out is to simply do both, but let the user choose if they also want to use the removable location, with a short explanation of why they may want to do that.

My opinion is this: the code as-is is broken, and it never made sense. We should either remove that fallback path entirely and only decide based on whether the user says they want to use the removable path or not, or we should do as this PR does currently, where the non-removable code path is tried first.

@h8d13
Copy link
Contributor

h8d13 commented Nov 27, 2025

From the Grub Wiki Page:

--removable

If you are installing GRUB on a [Mac](https://wiki.archlinux.org/title/Mac), you will have to use this option. 
Some desktop motherboards will only look for an EFI executable in this location, making this option mandatory, in particular with MSI boards.
If you execute a UEFI update, this update might delete the existing UEFI boot entries. 
Therefore, it is a potential fallback strategy to have the "removable" boot entry enabled.

It is a better default I think, generally speaking.

@mintsuki
Copy link
Contributor Author

It is not a good default, it's a fallback. At the very least the user should be prompted about it like Debian does. Recently merged PR #3932 adds a screen that prompts the user whether they want to install to the removable location or not.

@svartkanin
Copy link
Collaborator

For the sake of fixing this for now I'll merge the PR. The thing that I don't particularly like about it is that if a user does not set the removable setting now archinstall will simply go ahead and add it anyways on the failure.
It'd be good if there could be a check before running an installation if the selected setup is a viable or now and may lead to the error beforehand.

@svartkanin svartkanin merged commit 6fc0bc3 into archlinux:master Nov 29, 2025
9 checks passed
except SysCallError:
pass

raise DiskError(f'Could not install GRUB to {self.target}{efi_partition.mountpoint}: {err}') from err
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the fallback branch with --removable will always fall through and raise an exception here. Am I overlooking something?

mintsuki added a commit to mintsuki/archinstall that referenced this pull request Dec 5, 2025
As mentioned by @svartkanin on archlinux#3950, given we now have a way for the user to
explicitly specify if they want to install to the removable location, having a
fallback like this seems undesirable.

On top of that, as mentioned by @correctmost on the same PR, the code that said
PR introduced was bugged and would always raise an exception anyways.
svartkanin pushed a commit that referenced this pull request Dec 5, 2025
As mentioned by @svartkanin on #3950, given we now have a way for the user to
explicitly specify if they want to install to the removable location, having a
fallback like this seems undesirable.

On top of that, as mentioned by @correctmost on the same PR, the code that said
PR introduced was bugged and would always raise an exception anyways.
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.

4 participants