Subject: [bug#41011] [PATCH] gnu: grub: Support for network boot via tftp/nfs.

From: Stefan <[email-masked]>
Date: Sun, 24 May 2020 18:47:28 +0200

Hi Danny!

> Am 24.05.2020 um 15:42 schrieb Danny Milosavljevic <[email-masked]>:
> 
> You are totally right O_O
> 
> reinstall-bootloader says:
> 
>>         ;; Only install bootloader configuration file.
> 
> What happened here?  Why?!

From my point of o newbie view nothing, this has ever been so. :-)

> I think the actual bootloader (any of them those worked before) should be reinstalled by guix system delete-generations too, but apparently it doesn't do it right now.
> Sounds very dangerous.  Doesn't that mean if one changed bootloaders in the past and then keeps using guix system delete-generations, that one eventually couldn't boot anymore?  O_O

I think this may not be needed. The task of the bootloader is to parse the generated configuration file and load the initrd and kernel. If the current latest bootloader is able do this, than all is fine. The loaded system generation does not matter for this.

Why should 'guix system switch-generation' or 'guix system delete-generations' brake anything here, as long as the generated configuration file is still readable by the bootloader in use?

Ah, now I got your point! An older generation now potentially has a different value in the bootloader-name field of the <boot-parameters> record. Then it will generate the wrong bootloader configuration file, e.g. for extlinux instead of for grub-efi. 

Well, the bootloader-name information of an older system generation does not help.

> So the "brand new bootloader" case should be fine.
> But the delete-generation case basically would have had to do the actual bootloader installation too.  Like it is now, it totally has a huge problem.
> 
> A possible way around having to know which bootloader is in use would be to just always install the configurations for all the known bootloaders.

Hm, not sure.

>> Maybe the information about the bootloader version in use needs to reside with the installed bootloader somewhere below /boot/efi/…? But this may be impossible for the legacy grub-bootloader.
> 
> That sounds like a huge can of worms to open.  Better would be some kind of bootloader detector (can package "os-prober" do it maybe?)--or better yet, just also install the bootloader each time a system generation is deleted and/or system is reconfigured.  That was the original plan.

Some information from the installed bootloader could very well be passed via kernel arguments. This way the bootloader would actively spread information about itself and this will work with any bootloader. 

We could use for example these two kernel arguments:

--bootloader-configuration-file-generator=grub-configuration-file --bootloader-configuration-file=/boot/grub.cfg

If we – like today – do not reinstall the bootloader when switching generations, these are the needed information: how and where to generate the configuration file.

If the guix in $HOME does not know the passed generator procedure, then it there would automatically be a fallback: /var/guix/profiles/system/parameters contains a kernel-arguments field already! That would contain a matching generator function then. If the generator is neither in kernel-arguments, then we could fall-back to the bootloader-name field and even reinstall the bootloader.

As it is today, the bootloader is a state. And to reduce the risk of failures (power-loss), it makes sense to install the bootloader only if absolutely necessary.

Bye

Stefan