Boot options in rEFInd

Hi there,

recently I added the linux-lts to my setup. My /boot/refind_linux.conf looks like

"Boot with standard options"  "root=/dev/mapper/vg0-lvroot rw quiet rd.luks.name=<UUID>=cryptlvm initrd=intel-ucode.img initrd=initramfs-%v.img"
"Boot to single-user mode"    "root=/dev/mapper/vg0-lvroot rw quiet rd.luks.name=<UUID>=cryptlvm  single initrd=intel-ucode.img initrd=initramfs-%v.img"
"Boot with minimal options"   "ro root=/dev/mapper/vg0-lvroot initrd=intel-ucode.img initrd=initramfs-%v.img"

and I set the parameter within /boot/efi/EFI/refind/refind.conf

extra_kernel_version_strings linux-lts,linux

so rEFInd can pick up the kernels along the arch naming scheme. According the rEFInd documentation the kernels are sorted by their timestamp in descending order, so that the default option is to boot the latest kernel, which would be the linux-lts in my case. In order to have the standard linux kernel as default, I added a pacman hook in /etc/pacman.d/hooks

[Trigger]
Operation = Upgrade
Type = Package
Target = linux
Target = linux-lts

[Action]
Description = Touch vmlinuz-linux to become the latest kernel by timestamp.
When = PostTransaction
Depends = coreutils
Exec = /usr/bin/touch /boot/vmlinuz-linux

in order to have the `linux’ as default. Is there a better way to achieve this?

I think @freebird54 is the best to answer this one since he wrote the wiki. :slightly_smiling_face:

Edit: I have triple boot set up using rEFInd but i’m not using the lts kernel and i don’t have any options set up in rEFInd yet. I boot with grubx64.efi rather than the linuz-image.

1 Like

That should certainly do the trick - assuming the time elapsed between an update to linux-lts and the hook running is enough to be noticed! I can think of a coupls of other tricks that might work, but your solution looks good. Let me know if it works for you! The hard part is deciding how to call the linux-lts when you want it, though. At least rEFInd lets you know what it is going to boot before you select (under the icon list)…

I will look into this for you as well - I never bothered with lts after the first couple of weeks, as I have never needed more than a minimal recovery plan… usually arch-chrooting in to downgrade a (temporarily) bad kernel from either a live ISO or from another distro.

Maybe have a script handy for a touch on lts when you want to try it out - but I don’t see how that helps needing it for a boot substitute…

1 Like

Can’t say as I getting much further at the moment with this scenario. So far, I am left with the ‘obvious’ workaround. The fact that rEFInd can (and will) pick up a grub entry means that you can choose between them. The grub entry can be hidden (hit DEL to access the ‘hide this’ toggle) until it is required. In conjunction with the hook you propose should produce the desired capability. I would, however, put GRUB_DISABLE_OS_PROBER=true in /etc/default/grub, and let the current grub rebuild hooks operate as normal…

1 Like

I have three entries in the rEFInd menu, the Endeavour OS entry, one for a Linux Mint install and one for Windows. The first two entries are from the refind_linux.conf from the respective /boot partition. The Windows entry is a manual boot stanza within refind.conf in /boot/efi/EFI/refind

menuentry "Windows 10" {
    loader \EFI\Microsoft\Boot\bootmgfw.efi
}

I have no *.efi entry in the menu since I set the dont_scan_dirs to exclude all the EFI directories

dont_scan_dirs SYSTEM:EFI/Boot,EFI/EndeavourOS/,EFI/ubuntu,EFI/Microsoft,EFI/Microsoft/Boot

in order to keep the rEFInd menu free from those entries.

On Endeavour OS the default option is to boot vmlinuz from the EOS /boot partition. I can access all of the six options (three for vmlinuz, three for vmlinuz-lts due to the -%v variable) on pressing F2 on the Endeavour OS entry. So I can boot the LTS kernel from rEFInd without invoking grub. As far as I understood this rEFInd orders the kernels by timestamp, so vmlinuz may be default, but vmlinuz-lts could be default, too, if it is updated. My pacman hook should ensure that vmlinuz is always the latest kernel (I guess I could add a sleep before the touch to add a extra certainty on this).

So far this works, but I was just wondering if I’m missing a setting in rEFInd which could make this hook unnecessary.

Not sure about that at all. Have you tried it without? If n othing else, there is a setting in /boot/efi/EFI/refind/refind.conf that will default the ‘selected choice’ to the most recent ‘last boot’ - which should obviate the need for a ‘default’ of any other kind. Again - I haven’t got that setup on the go at the moment, so I can’t check it right now, but I see no reason that shouldn’t handle the situation for you. I guess I could try that on one of my secondary systems, but you’ll probably have the answer before I do!

Please try it and let me know - it is time I updated some things in that wiki anyway :grin:

Taken from the documentation of the dev, who does an excellent job BTW:

rEFInd sorts boot loader entries within each directory by time stamp, so that the most recent entry comes first. Thus, if you specify a directory name (or a volume label, for loaders stored in a volume’s root directory) as the default_selection, rEFInd will make the most recent loader in the directory the default. This can obviate the need to adjust this configuration parameter when you add a new kernel; chances are you want the most recently-added kernel to be the default, and rEFInd makes it so when you set the default_selection in this way. If you don’t want the latest kernel to become the default, you can use touch to give the desired kernel (or other boot loader) in the directory a more recent time stamp, or you can set default_selection to a value that uniquely identifies your desired default loader. One caveat you should keep in mind is that the EFI and Windows interpret the hardware clock as local time, whereas macOS uses Coordinated Universal Time (UTC). Linux can work either way. Thus, time stamps for boot loaders can be skewed by several hours depending on the environment in which they were created or last modified.

[highlight on touch by me]

There is the option default_selection with the possible setting

default_selection "+,bzImage,vmlinuz"

which selects my Endeavour OS entry correctly when I chose it in the last boot, but still would select the LTS kernel if it the latest because rEFInd sorts the kernels in descending order, matches “vmlinuz” and finds the LTS kernel.

So after all I guess right now that the touch method should yield the result I want here. I will have a closer look at this in the next weeks.

BTW: this is the type of discussion I like to have here. Even if this is not the best solution I learned a lot on my way to it :+1:

2 Likes