Persisting a Default Kernel with systemd-boot
I use systemd-boot instead of
Grub. It's pretty barebones, which I like. It simply presents a boot menu and
then gets out of the way. Like other boot managers, it allows you to set the
default boot entry. I just need to set the default=
key in
/efi/loader/loader.conf
to reference one of the .conf
files in
/efi/loader/entries/
(e.g.,
00000000000000000000000000000000-6.14.6-arch1-1.conf
). This setup works well.
However, in a rolling-release distro like Arch, where kernel packages are
frequently updated, there's an issue to address.
Arch provides two kernel packages: linux
, which tracks the latest stable
kernel, and linux-lts
, which tracks the latest LTS kernel version. Having the
LTS kernel installed simultaneously gives me a handy fallback if a new mainline
kernel makes it so I can't boot. The problem arises when updating linux
or
linux-lts
packages. The .conf
filenames change, invalidating the default=
value. Ideally, I could make the default entry track either the mainline or LTS
kernels regardless of explicit version.
Well, I can! The default=
field accepts patterns. So, instead of
00000000000000000000000000000000-6.14.6-arch1-1.conf
, you can use
00000000000000000000000000000000-*-arch?-?.conf
and, boom, you're always on
the latest stable version.
You may be wondering what the field 00000000000000000000000000000000
represents - that's your machine
ID.
It's a 32-character hexadecimal ID. You can see yours via cat
/etc/machine-id
.