You are viewing a single thread.
View all comments
0 points

If you use btrfs snapshots and systemd-boot instead of grub, then be carefull restoring updates from before a kernel update.

If I understand it correctly, with systemd-boot the kernel lives in the EFI partition, while the kernel modules live in the main (btrfs) partition. If you restore a snapshot with a different kernel version, it doesn’t restore the kernel itself, but the kernel modules have different filenames, which stops the system from being able to boot.

At least that is my understanding of the problem, from having to debug it twice (just start a live-boot system and use Timeshift to restore the system to after the update again). The next time I install Linux, I think I’ll go with grub instead of systemd-boot.

That being said, I really like btrfs snapshots as a sort of “almost backup” (still do regular backups on an external drive). They are quick and easy, and most packet managers can be setup to automatically make a snapshot before installing/updating stuff.

permalink
report
reply
0 points

The kernel in the EFI partition is used as a tool to bootstrap hardware and memory for your proper kernel, which is chainloaded.

There is a simple reason for that: The Linux kernel can do anything a bootloader needs to do, especially for itself, so why not use it as one?

That said, in most setups there is another bootloader before that, which loads the kernel itself and the initramfs for that kernel. That can be for example systemd-boot, formerly known gummiboot, a minimal bootloader meant to (auto-)discover EFI compatible stuff it can load.

Dracut creates a setup / boot chain like that.

permalink
report
parent
reply
0 points

Thanks for explaining it! So systemd-boot finds the kernel in the EFI partition, which it then loads, and then that kernel loads another kernel from the main partition, which is then the full OS.

Is there a reason it’s done this way, and not just the bootloader loads the main kernel?

Also, are the two kernels the same, or does this use two different kernels?

permalink
report
parent
reply
0 points
*

In the case of Dracut, I’m not sure what it does exactly, but the kernels will almost definitely not be identical. In the “EFI kernel”, uneeded modules (meaning most of them) are usually omitted.

You could probably also have different kernels in terms of version number, although it might complicate things. Kinda depends on whether they recycle data structures from the first kernel and whether those remain compatible. I don’t really know whether this is actually done tho.

The reason why multiple kernels (or bootloaders for that matter) are used is that there are different levels of “readiness” in your system. Say you have LVM and a LUKS encrypted partition (in whatever order). Systemctl-boot will load the kernel and it’s initramfs, but can’t be bothered to deal with complicated file system shenanigans. That would complicate the whole program significantly.

So it just loads a Linux kernel which has these capabilities. That kernel can deal with LVM, decrypt the LUKS partition (or ask for a password), mount whatever btrfs nonsense is inside and then hand it over to the proper kernel. The proper kernel can in turn rely on having all its stuff mounted and ready, instead of having to worry about all this.

You could do with just one kernel, but Dracut allows you to rapidly create bootable kernel + initramfs pairs of which you might need multiple (e.g. for dual booting, backup). Moreover, you probably wouldn’t really want it to fiddle with your kernel all the time, especially when it’s customised already.

permalink
report
parent
reply
0 points

Sorry for the late reply btw, responses were broken for me

permalink
report
parent
reply

linuxmemes

!linuxmemes@lemmy.world

Create post

I use Arch btw


Sister communities:
Community rules
  1. Follow the site-wide rules and code of conduct
  2. Be civil
  3. Post Linux-related content
  4. No recent reposts

Please report posts and comments that break these rules!

Community stats

  • 7.4K

    Monthly active users

  • 910

    Posts

  • 15K

    Comments