Bug 2323514 - 92-tuned.install incompatible with systemd-boot - prevents boot
Summary: 92-tuned.install incompatible with systemd-boot - prevents boot
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: tuned
Version: 41
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Jaroslav Škarvada
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2323348 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-11-03 15:48 UTC by Martin Pilarski
Modified: 2024-11-12 03:33 UTC (History)
8 users (show)

Fixed In Version: tuned-2.24.0-6.fc42 tuned-2.24.0-6.fc41
Clone Of:
Environment:
Last Closed: 2024-11-05 02:11:37 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Martin Pilarski 2024-11-03 15:48:41 UTC
The script "/usr/lib/kernel/install.d/92-tuned.install" puts the $tuned_initrd variable into the initrd line of all boot loader entries (except the rescue image entry).

The variable is not compatible with systemd-boot & prevents boot of the system (Error preparing initrd: not found).

Because all entries are affected, the upgrade from 40 to 41 resulted in a broken system (rescue image didn't seem to work for a different reason).

The system uses the ESP as /boot-partition, as described in https://systemd.io/BOOT/ (i.e. boot loader entries are under /boot/loader/entries/).

$tuned_params in the options line has no effect on the boot.


Reproducible: Always

Steps to Reproduce:
1. Install kernel
Actual Results:  
Boot is prevented due to the incompatible "$tuned_initrd" variable put into the initrd line

Expected Results:  
System boots normally

https://discussion.fedoraproject.org/t/kernel-install-92-tuned-install-is-conflicted-with-systemd-boot/134899

Comment 1 Jaroslav Škarvada 2024-11-04 11:19:19 UTC
(In reply to Martin Pilarski from comment #0)
> The script "/usr/lib/kernel/install.d/92-tuned.install" puts the
> $tuned_initrd variable into the initrd line of all boot loader entries
> (except the rescue image entry).
>
This is intended.

> The variable is not compatible with systemd-boot & prevents boot of the
> system (Error preparing initrd: not found).
>
It's using grub environment to easily reconfigure boot arguments. Unfortunately, I don't know how to support this feature with systemd-boot. This will require discussion with the systemd guys.
 
> Because all entries are affected, the upgrade from 40 to 41 resulted in a
> broken system (rescue image didn't seem to work for a different reason).
>
Only with systemd-boot. I think systemd-boot should ignore it. But even in such case the TuneD feature will not work with systemd-boot.

> The system uses the ESP as /boot-partition, as described in
> https://systemd.io/BOOT/ (i.e. boot loader entries are under
> /boot/loader/entries/).
> 
> $tuned_params in the options line has no effect on the boot.
> 
It will have effect if you select some TuneD profile utilizing bootloader plugin and setting custom initrd overlays.

Comment 2 Jaroslav Škarvada 2024-11-04 13:35:22 UTC
*** Bug 2323348 has been marked as a duplicate of this bug. ***

Comment 3 Jaroslav Škarvada 2024-11-04 13:44:33 UTC
IMHO workaround is to add empty (untested):
/etc/kernel/install.d/92-tuned.install

Comment 4 Jaroslav Škarvada 2024-11-04 13:58:06 UTC
Is there a way how to reliably detect that system is using systemd-boot instead of the grub? I will add workaround into 92-tuned.install.

Interesting, that nobody hit/reported it during F41 test days.

Comment 5 Jaroslav Škarvada 2024-11-04 16:33:59 UTC
(In reply to Jaroslav Škarvada from comment #4)
> Is there a way how to reliably detect that system is using systemd-boot
> instead of the grub? I will add workaround into 92-tuned.install.
> 
Or maybe rather the other way round, as it's grub extensions, i.e. enable it in case grub is detected.

Comment 6 Mike Beaton 2024-11-04 17:02:12 UTC
I've been redirected here https://github.com/redhat-performance/tuned/issues/704#issuecomment-2455170137, though I raised a slightly different (but closely connected) issue, which is that after _upgrading_ to Fedora 41, the loader/entries files use these variables, as discussed above, but grub.cfg is not automatically updated to set a value for them.

Empty values only appear in grub.cfg after we re-run grub2-mkconfig or if we install a TuneD profile which actually uses these values (e.g. with [bootloader] cmdline_...=... &/or initrd_add_img=...).

This doesn't stop anything booting, but it seems to go against a stable convention that grub variables are always defined if referred to, in a well-set-up system. (And makes it harder for any third party software which wants to parse loader/entries, and relies on this convention, to do its work.)

Once one of the above steps is run, TuneD also inserts the values for tuned_initrd and tuned_params into grubenv. I do wonder if this is wise (grubenv has very limited space and these variables can be long; it is not clear why they are needed in both places?), but it looks as if a quick fix could involve adding initial blank values in either place.

Comment 7 Jaroslav Škarvada 2024-11-04 19:33:54 UTC
PoC PR:
https://github.com/redhat-performance/tuned/pull/705

Comment 8 Jaroslav Škarvada 2024-11-04 19:43:27 UTC
(In reply to Mike Beaton from comment #6)
> I've been redirected here
> https://github.com/redhat-performance/tuned/issues/704#issuecomment-
> 2455170137, though I raised a slightly different (but closely connected)
> issue, which is that after _upgrading_ to Fedora 41, the loader/entries
> files use these variables, as discussed above, but grub.cfg is not
> automatically updated to set a value for them.
> 
> Empty values only appear in grub.cfg after we re-run grub2-mkconfig or if we
> install a TuneD profile which actually uses these values (e.g. with
> [bootloader] cmdline_...=... &/or initrd_add_img=...).
> 
> This doesn't stop anything booting, but it seems to go against a stable
> convention that grub variables are always defined if referred to, in a
> well-set-up system. (And makes it harder for any third party software which
> wants to parse loader/entries, and relies on this convention, to do its
> work.)
> 
> Once one of the above steps is run, TuneD also inserts the values for
> tuned_initrd and tuned_params into grubenv. I do wonder if this is wise
> (grubenv has very limited space and these variables can be long; it is not
> clear why they are needed in both places?), but it looks as if a quick fix
> could involve adding initial blank values in either place.

There was no related change on the TuneD side. I will try to reproduce it.

Regarding the grubenv, IMHO it has 1024 bytes limit and there can be other variables. Regardless the limit it's clean and usually safe solution - edit kernel/initrd parameters just by changing variables. But taking into account recent systemd-boot deployment, we will have to rewrite it, which will also resolve the grubenv limit problem.

Comment 9 Jaroslav Škarvada 2024-11-04 23:46:24 UTC
(In reply to Jaroslav Škarvada from comment #3)
> IMHO workaround is to add empty (untested):
> /etc/kernel/install.d/92-tuned.install

This workaround worked for me.

The problem also doesn't occur if ESP partition is moved from /boot/efi to /efi as suggested by some guidelines.

Comment 10 Fedora Update System 2024-11-05 00:20:07 UTC
FEDORA-2024-ec96d2567e (tuned-2.24.0-6.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-ec96d2567e

Comment 11 Fedora Update System 2024-11-05 00:42:48 UTC
FEDORA-2024-e0e2d7c34a (tuned-2.24.0-6.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-e0e2d7c34a

Comment 12 Fedora Update System 2024-11-05 02:11:37 UTC
FEDORA-2024-ec96d2567e (tuned-2.24.0-6.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 13 Mike Beaton 2024-11-05 09:01:34 UTC
By the way, TuneD is definitely not the only software to use grub variables in /loader/entries. I work on a non-GRUB BLSpec compliant bootloader, and we definitely had to write heuristic processing to extract variable values from grub.cfg in order to get most Linuces to boot. Including defaultkernelopts - which grub blscfg applies if there are not other kernel options. But there are definitely other distros, which use other vars in kernel options.

The specific problem with $tuned_initrd is worse for sd-boot (and other BLSpec compliant loaders) than just having an unknown variable in options, because the kernel ignores unknown options (option `$myopt` will be ignored, but will probably boot - unless what is was meant to expand to is required).

Having $tuned_initrd in the initrd line is slightly non-obviously different and harder to ignore (intentionally, or by mistake):

Firstly, unknown values are not ignored here, they are treated as unloadable files.

Secondly, BLSpec does eeven not allow multiple initrd files in one line, as is being done here, there are meant to be in separate initrd lines. But grub+blscfg does allow this. So from sd-boot's point of view, the file is `initrd-version.img $tuned_initrd` (a file name with ' '  and '$' in it). Not that it is much better even if we allow that it means two files `initrd-version.img` and `$tuned_initrd`, because sd-boot does not know about `$tuned_initrd`.

I wonder if there is any scope for proposing a shared, simple-to-parse variable store, next to /loader/entries, which both BLSpec and grub+blscfg are aware of, but which is the only place which /loader/entries variables can come from, so that BLSpec when done independently if grub can also find and use these. (I am not sure how/where/whether to propose this...)

Comment 14 Jaroslav Škarvada 2024-11-05 13:35:49 UTC
(In reply to Mike Beaton from comment #13)
> Secondly, BLSpec does eeven not allow multiple initrd files in one line, as
> is being done here, there are meant to be in separate initrd lines. But
> grub+blscfg does allow this. So from sd-boot's point of view, the file is
> `initrd-version.img $tuned_initrd` (a file name with ' '  and '$' in it).
> Not that it is much better even if we allow that it means two files
> `initrd-version.img` and `$tuned_initrd`, because sd-boot does not know
> about `$tuned_initrd`.
>
We implemented this feature long time ago into TuneD when BLS even didn't exist and later ported it to BLS and used grub as the reference implementation, because at that time there wasn't other working BLS option. Multiple initrd lines shouldn't be problem, we could switch to this format. It's question whether it can cope with initrd lines with empty path, but even in such case we could workaround it by e.g. empty initrd, strange, but it may work.

> I wonder if there is any scope for proposing a shared, simple-to-parse
> variable store, next to /loader/entries, which both BLSpec and grub+blscfg
> are aware of, but which is the only place which /loader/entries variables
> can come from, so that BLSpec when done independently if grub can also find
> and use these. (I am not sure how/where/whether to propose this...)

This would be great to have and it would make our life simpler. I think the best would be to get it into BLS specification, next revision. To be honest I thought it's already there or at least mentioned as optional extension, but unfortunately it is not.

Comment 15 Fedora Update System 2024-11-06 07:00:50 UTC
FEDORA-2024-e0e2d7c34a has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-e0e2d7c34a`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-e0e2d7c34a

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 16 Fedora Update System 2024-11-12 03:33:36 UTC
FEDORA-2024-e0e2d7c34a (tuned-2.24.0-6.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.