You are not logged in.

#1 2024-11-11 16:17:18

eteq
Member
Registered: 2022-09-10
Posts: 4

Conditionally selecting a kernel to boot to in systemd-boot

I have a systemd-boot based setup where I have two different arch entries for two different configurations, where the easiest fix for some hardware quirks is to just use a different set of kernel parameters depending on what is plugged in.

However, this can be annoying: one of the pieces of hardware is an EGPU, which means I can't necessarily see the screen to select the right boot entry.  So what I would prefer is if there were some script or something that looks for the connected device, and then chooses between the two boot entries or even just have a single entry with two different kernel invocations with different kernel parameters.

The problem is, I see nothing in the systemd-boot man pages about how to do really anything conditionally.  Is this even possible, or do I need to go down another path of trying to convince the kernel to change some of its choices after it has started up?

Offline

#2 2024-11-11 16:33:26

Awebb
Member
Registered: 2010-05-06
Posts: 6,602

Re: Conditionally selecting a kernel to boot to in systemd-boot

Offline

#3 2024-11-11 18:24:55

eteq
Member
Registered: 2022-09-10
Posts: 4

Re: Conditionally selecting a kernel to boot to in systemd-boot

Yes, that's definitely the right direction (although I have slightly more complex of an if statement than "is this GPIO high or low"), but it looks like that uses GRUB, which seems to have much better "scripting" capability than systemd-boot loader entries.  So sharpening the question might be: "can that be done with systemd-boot instead of grub?"

Offline

#4 2024-11-12 01:31:09

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,202

Re: Conditionally selecting a kernel to boot to in systemd-boot

Directly? No. You might be able to write an EFI binary and preload that which will in turn chainload your actual kernels. But for the goal you envision systemd-boot on its own will not cut it.

Last edited by V1del (2024-11-12 01:31:31)

Offline

#5 2024-11-12 07:24:05

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,277
Website

Re: Conditionally selecting a kernel to boot to in systemd-boot

The UEFI shell can be used by systemd-boot: https://wiki.archlinux.org/title/System … other_disk


Para todos todo, para nosotros nada

Offline

Board footer

Powered by FluxBB