Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] nixos/refind: init #58121

Closed
wants to merge 2 commits into from
Closed

Conversation

betaboon
Copy link
Contributor

@betaboon betaboon commented Mar 22, 2019

Motivation for this change

I wanted to use refind instead of systemd-boot.

I have been running this for almost a year now.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@betaboon
Copy link
Contributor Author

@AndersonTorres maybe you are capable of giving some review-notes, as you are marked as the maintainer for the refind-package ?

@aanderse
Copy link
Member

ping (triage)

@betaboon
Copy link
Contributor Author

@disassembler @lheckemann I would love to get this into 19.09

@lheckemann
Copy link
Member

lheckemann commented Aug 14, 2019

I like the idea, but I'm not very comfortable with having a bootloader option without tests — breaking people's boot would suck! Any chance you could add tests to this?

@betaboon
Copy link
Contributor Author

@lheckemann I'll look into it

@betaboon
Copy link
Contributor Author

looking at the following files i am completly lost on how to write tests for this:

@lheckemann
Copy link
Member

If the lack of tests and the implication of that is mentioned in the enable option's documentation, I guess I'd be fine with merging this as is as well.

@betaboon
Copy link
Contributor Author

betaboon commented Sep 3, 2019

@lheckemann i think i got it figured out how to write a proper test for this. I'm gonna spend some more time on this on thursday and friday.

@betaboon
Copy link
Contributor Author

betaboon commented Sep 6, 2019

@lheckemann so i played around some more but i just get it to work in the virtualmachine that is used for the tests.

@lheckemann
Copy link
Member

So what's the problem?

@Ninlives
Copy link
Contributor

Any progress?

@betaboon
Copy link
Contributor Author

sorry for not reporting back.
my notebook had an unfortunate encounter with a full cup of black-gold ...
followed by a lot happening in my personal life.

@lheckemann as far as i remember the problems i encounter where something along these lines:

  • the initial nixos installation (by nixos/tests/installer.nix) seems to be run in bios-mode even tho isEfi is set
  • refind seems to have a problem installing in that mode (systemd-boot does not)
    -> refind will start on restart of test-vm after initial installation but will not find its configuration

that's where i got stuck and then i couldnt work on it any further.
i will try to pick this up as soon as i find the time.

sorry for the delays.

@betaboon betaboon force-pushed the refind-boot-loader branch 2 times, most recently from ca5157b to 0bb49f9 Compare November 10, 2019 21:27
@betaboon
Copy link
Contributor Author

@lheckemann i think this is now done.

@samueldr
Copy link
Member

samueldr commented Nov 11, 2019

It is fine if only "as removable" is tested, just like it is fine for GRUB2.

The current test driver makes it impossible to sanely test with a writable nvram. I tried adding the ability to do so, but there are just too many assumptions in the current test driver. In addition there is the new test driver in python, so I'm not too keen on improving anything for now :/. Either I need to port the installer test to python, or I have to rework the perl test driver which may be soon deprecated, if not removed.

Basically, the issue is two-fold:

  • The first boot cannot be configured with qemu flags. The first boot is always as legacy boot.
  • Then, once fixed, the test driver must use pflash options to setup the EFI.

Something similar to the following, where there is the OVMF code (the EFI), and another writable drive for the NVRAM. Unverified still, but the secondary drive may need to be started from a copy of OVMF_VARS.

-drive if=pflash,format=raw,readonly,file=$args->{efi} 
-drive if=pflash,format=raw,file=$tmpDir/vm-state-machine/nvram.fd

@stale
Copy link

stale bot commented Apr 26, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 26, 2021
@colemickens
Copy link
Member

@betaboon @samueldr this is still mildly interesting to me. what's the status of it nowadays?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 26, 2021
@betaboon
Copy link
Contributor Author

I'm using it on a daily basis for ages.
back when i opened this PR i was asked to implement tests (for good reasons).
adding support for efi-boot to the test-infrastructure was quite an endeavour.
sadly soon after i had it working there were major changes to the test-infrastructure which resulted in the efi-boot-support requiring alot of rework which i never got around to.

@AndersonTorres
Copy link
Member

The only issue is the test, then?

@betaboon
Copy link
Contributor Author

The only issue is the test, then?

i would have to check if the code in this PR is what I'm running. not sure as this PR is old.

If there is interest to get this going i could try to find some time.

@samueldr
Copy link
Member

samueldr commented Apr 27, 2021

This is probably one of the hardest PR I've been involved into reviewing.

On the one hand, this is an amazing feature, and seems to work just fine... And the contribution has great value.

But on the other... Testing that the bootloader generation is not broken is primordial. This is because it would lock people out of their system if it fails.

Though, as we discussed earlier, a simpler test where we use the fallback location, like GRUB2 currently does, would be good to go forward. We care more about the fact that the bootloader still understand what configuration we generate than the actual initial installation and configuration steps.

@betaboon
Copy link
Contributor Author

i totally agree that this should have rock-solid tests.
It's one thing if i lock myself out of my system, but it's a completly other thing if that happens to someone else.

the hardest thing about the tests was to implement support for booting via EFI on the very first boot (which is what #73768 adressed).
It is a non trivial change.

there are several scenarios to be covered by tests:

  • initial boot in BIOS-mode -> install EFI -> reboot into EFI-mode
  • initial boot in EFI-mode -> install EFI -> reboot into EFI-mode

@samueldr
Copy link
Member

If, just like with GRUB, we only test the "default fallback location" (/EFI/BOOT/bootx64.efi, /EFI/BOOT/bootaa64.efi) install, we should be good to go since it at least tests the generations file format.

Anyway, installing at the fallback location would be a requirement for some platforms, like U-Boot's UEFI on ARM. And also required on some bad UEFI implementations.

@AndersonTorres
Copy link
Member

Thinking like Ryuuguin Seiya, the Overly Cautious Hero, how could we devise an intermediate phase?

I am thinking in something like that:

  • Start in GRUB;
  • Put an option "Boot refind" in GRUB menu

This way, if refind does not boot, then it is just a matter of reboot the system and use the GRUB options.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-use-refind-as-boot-manager/13507/5

@Artturin
Copy link
Member

Artturin commented Dec 1, 2021

Thinking like Ryuuguin Seiya, the Overly Cautious Hero, how could we devise an intermediate phase?

I am thinking in something like that:

* Start in GRUB;

* Put an option "Boot refind" in GRUB menu

This way, if refind does not boot, then it is just a matter of reboot the system and use the GRUB options.

@cstrahan does that https://github.com/cstrahan/nixos-config/blob/1ec7e813efdaf934014c191a7cdf021bc5f6cb79/configuration.nix#L84

@TheOPtimal
Copy link

any update on this?

@AndersonTorres
Copy link
Member

None. The OP seems to lose interest.

@TheOPtimal
Copy link

Damn, the only thing missing are the tests.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 21, 2022
@nayr7
Copy link

nayr7 commented Dec 19, 2022

This is important to me. What is the state of efi-boot in the test infractrusture? Is any trivial patch possible ? I am willing to help but I am missing information here.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 19, 2022
@AndersonTorres
Copy link
Member

This is important to me. What is the state of efi-boot in the test infractrusture? Is any trivial patch possible ? I am willing to help but I am missing information here.

I can't help so much. Maybe open a thread on Matrix and/or another on Discourse.nixos.org can be helpful.

@Atemu
Copy link
Member

Atemu commented Dec 20, 2022

Since this doesn't look like it'll be moving any time soon, I'll close this for clarity. You can re-open if you gain interest again.

@Atemu Atemu closed this Dec 20, 2022
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/easy-refind-boot-by-booting-into-systemd-boot-from-refind/28507/1

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-add-bootentry-booting-straight-into-latest-generation/33507/2

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

Successfully merging this pull request may close these issues.

None yet