Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow glob or regex kernel matching rather than substring #759

colmbuckley started this conversation in Feature Requests
Allow glob or regex kernel matching rather than substring #759
Jul 22, 2025 * 1 comments * 7 replies
Return to top
Discussion options

colmbuckley
Jul 22, 2025

TL;DR: maybe allow org.zfsbootmenu:kernel to be a glob or regex pattern.

My situation; I have a number of systems which perform tasks like building modules for other systems. In order to achieve this, the kernel sources for the target systems need to be installed and, on some distributions (eg: recent Debian), this also brings in the kernel images for the target systems. However, obviously these might not be bootable on the current system.

I can set the desired kernel in org.zfsbootmenu:kernel of course, but there's a bit of a potential race condition here; if the system reboots before I have the opportunity to correctly set the kernel, there's a chance that an unbootable kernel will be chosen by ZBM's algorithm, necessitating tedious recovery.

If org.zfsbootmenu:kernel were interpreted as a glob or regular expression which filtered the available kernels in the relevant dataset and then chose the last one (ordered by version string), I think that would still be compatible with current usage, but also allow for richer automatic kernel selection.

Suppose for example we had the following kernels installed in /boot:

vmlinuz-6.12.32+bpo-amd64
vmlinuz-6.12.32+bpo-cloud-amd64
vmlinuz-6.12.33+deb12-amd64
vmlinuz-6.12.33+deb12-cloud-amd64
vmlinuz-6.15.5+exp1-amd64
vmlinuz-6.15.5+exp1-cloud-amd64

If I never wanted the current machine to boot any experimental kernels, and also exclude the -cloud- variants, I could set org.zfsbootmenu:kernel to something like *+[bd]*[o0-9]-amd64 and from the list above it would only match the first and thirs, and would pick vmlinuz-6.12.33+deb12-cloud-amd64 as the last in that list.

This might end up a bit inelegant with globs, so regular expressions might be better - maybe if org.zfsbootmenu:kernel begins and ends with / it would be interpreted as a regular expression, so we could set it to /(bpo|deb[0-9]+)-amd64$/ which would be clearer? This would not break any existing usage, as we would never expect to see / in an existing version string.

You must be logged in to vote

Replies: 1 comment 7 replies

Comment options

colmbuckley
Jul 22, 2025
Author

LOL; I just looked at the code... the comparison is already done using [[ "${kernel}" =~ ${specific_kernel} ]] so I guess this should already work...

You must be logged in to vote
7 replies
Comment options

colmbuckley Jul 22, 2025
Author

Just wanted to confirm; the loop over ${kernel_list} at around line 945 of zfsbootmenu-core.sh will result in picking the last kernel which matches ${specific_kernel} right? And $kernel_list is sorted by version string (ie: using the linux-version comparison)?

Just want to make sure you're covering the case where more than one kernel might match, and we want the most recent of the matching ones.

Comment options

zdykstra Jul 22, 2025
Maintainer

Yes, if you were to set the value to say, 6.12, the selection loop would pick the kernel name with the highest version number that includes that string.

Comment options

colmbuckley Jul 22, 2025
Author

Reading the code again; I'm sure the sort -V will be correct in almost all situations. Debian's linux-version command's man page insists that there's a difference in kernel version numbers, but I suspect this is to deal with Debian's complex epoch and branch system.

Comment options

colmbuckley Jul 22, 2025
Author

Thank you; this is awesome.

Comment options

ahesford Jul 22, 2025
Maintainer

We should probably just pull the language from the Kernel.Version description in generate-zbm(5). That page already mentions globs and the sorting behavior.

These two version parameters are intended to be more or less equivalent. while we could mention regular expressions, the fact that one is interpreted by bash and the other by Perl may lead to confusion as there can be subtle differences. It may be best for people to discover for themselves that they can get more sophisticated than globbing.

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