ZFSBootMenu
docs.zfsbootmenu.org
docs.zfsbootmenu.org
If you have your own server in a rack somewhere chances are you bought one with a similar web interface (IMPI/BMC/whatever your brand calls it) on a separate always-on NIC on the mainboard.
https://docs.hetzner.com/robot/dedicated-server/maintainance...
This way I didn’t have to request KVM access for my servers.
Perhaps a similar method can be used in order to install ZFSBootMenu
I should probably specify though that I do this when setting up a new server.
If you fail then it should still be possible to select their Linux rescue image again from the Hetzner control panel and force reboot the server.
I seem to recall that I had to try a couple of times before I got it right. And that I did exactly that; select their rescue image again and force reboot.
One issue to look out for is the activated features and the ZFS module in the kernel and in ZFSBootMenu - these should match as depending on the features it's not possible to import the pool otherwise.
zfsbootmenu just looks for kernels and boots them. If something fails you can go back to an older snapshot or use an older kernel - and you have an emergency shell.
That bootloader needs to mount a filesystem to find the kernel.
The kernel needs to mount the filesystem to run the system.
Each of those mount operations is done with different code, and normally each involves some config or search process to find the right disk/partition. If any of the searches finds the wrong partition or is misconfigured, you get a boot failure.
It really feels like the boot process is more complex than it needs to be, with more opportunities for failure than necessary.
That said, there are only two steps in the modern boot process on a PC: the UEFI firmware loading a basic FAT driver and the kernel mounting the other filesystems. The UEFI bootloader can use the existing FAT driver to load the kernel and the initramfs which will use the same code to mount partitions.
You can skip the UEFI bootloader and directly boot unified kernel images after putting them on the UEFI partition.
That effectively removes all config from the process - and means that any disk with a uefi executable kernel can be booted without the mystery step of "lets try to figure out where we're booting from".
I think UEFI gives an EFI application (such as the Linux kernel) everything it would need for this already - but I guess Linux doesn't use it.
The EFI application entry point includes a handle to your own image [0], and the EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID [1] protocol allows you to query the path it was loaded from. It is possible for an image to be loaded without a path, but it looks like EDK2 provides it at least [2].
[0] - https://uefi.org/specs/UEFI/2.10/07_Services_Boot_Services.h...
[1] - https://uefi.org/specs/UEFI/2.10/09_Protocols_EFI_Loaded_Ima...
[2] - https://github.com/tianocore/edk2/blob/991515a0583f65a64b3a6...
https://uapi-group.org/specifications/specs/discoverable_par...
You can use EFISTUB kernels directly (through efibootmgr) and use UEFI bios as the bootloader. There is no automatic kernel discovery with this method of course.
Does it have a kernel too?
Theoretically it should be possible to flash Linux Kernel onto BIOS Flash ROM to directly load and run it from there. But x86 being x86, you also have to have bunch of circus tricks to initialize motherboard and to get out of 16-bit 8086 compatible mode and to load Kernel from disk, in such hypothetical Kernel image. BIOS/UEFI and bootloader each do parts of those.
"I have come to bury the BIOS, not to open it: The need for holistic systems" https://www.osfc.io/2022/talks/i-have-come-to-bury-the-bios-...
This also talks about how you need a boot processor to do things like train up the RAM interface just so you can boot the main processor.
The kernel needs to mount the filesystem to run the system.
Each of those mount operations is done with different code...
Not on FreeBSD. Our bootloader reuses kernel code (because, you know, developing the entire operating system together makes this possible).
I'm not sure what the complaints are about mounting filesystems. Unless you want to raw-dump your kernel and other components necessary for booting to some known offset on the disk, you'll always have to walk some filesystem to find the kernel. This even happens in the FreeBSD boot process, where one of the stages has to go looking at the filesystem for a kernel.
The Linux kernel can act as an EFI binary/application using a mechanism/feature called EFISTUB and thus can be loaded directly. The concept of a "bootloader" in UEFI-based Linux system is mostly vestigial (to enable feature-parity with non-UEFI systems or work around broken firmware). On a non-defective UEFI firmware, a bootloader is unnecessary, the UEFI firmware can load your kernel and initrd directly from the EFI system partition.
Ideally you'd want your UEFI to be able to read and understand your main filesystem (ZFS in this case) which means you no longer need a separate EFI system partition to store your kernel/initrd (and can enjoy the redundancy and features provided by your filesystem of choice). UEFI is actually extensible so you can have third-party drivers (you'd need to store those drivers somewhere, but a USB stick/memory card would do, or you could technically embed it in your firmware)?
The problem when it comes to ZFS specifically is that there is no UEFI-based driver with feature parity to the main ZfsOnLinux project. GRUB has a primitive implementation (extracted as stand-alone EFI drivers here: https://efi.akeo.ie) but it lacks support for many features, effectively forcing you to have a separate boot-time ZFS partition with all unsupported features disabled (if you're going to use a separate partition, why not just use FAT32 which is natively supported).
I've long switched to compiling my kernel including all needed modules and the EFI stub. I don't have initrd or bootloader anymore, and can boot in a few seconds.
GRUB has some slight improvements like running other operating systems, but that's about it. Unsure if it's worth the price...
None of this crazy modern boot-time ouroboros. Too many layers, too much software.
At least we should _get_ something for this. How about a 2s cold boot on my thinkpad?
https://docs.zfsbootmenu.org/en/v2.2.x/guides/general/remote...
One concern I had with zfsbootmenu was I couldn't figure out how to load microcode. With kexec, zfsbootmenu can only load one image and late loading microcode may be "dangerous" [1]. I don't know practically if that is a real security issue or not. I tried cat'ing my images together as below, but it still didn't work for me:
mv initramfs-linux.img initramfs-linux.img.orig
cat intel-ucode.img initramfs-linux.img.orig > initramfs-linux.img
[1] https://docs.kernel.org/arch/x86/microcode.html#why-is-late-...I started ZBM years ago by hacking on the same grub script, then progressed to what it is now!
Then switching to ZBM, while it did boot with the concatenated image, I didn't see microcode loaded in dmesg.
In case 2 portage changes are automatically synchronized to system snapshots, but multiple system instances (VMs, diskless nodes, etc.) will have to redundantly update portage. However, in case 1 they are de-facto desynced and this can cause gentoo issues (yet saves duplicate network operations so is nominally desirable). Does ZFSBootMenu have a built-in system for managing ZFS root system snapshots with co-dependent dataset snapshot versions to enable case 1?
After writing the grandparent comment I realised some people (in particular distro devs, I suspect) may treat kernel module datasets in a similar fashion, which provides a very similar use case.
I wonder if - zfs dataset mountpoints and snapshot timings aside (both of which are already embedded in zfs) - it could be worth considering adding some zfs dataset properties as hints.
One idea (half-baked) are "zfsbootmenu-boot-significant" = "true" for ZFSBootMenu guesses for adding a default inference of latest/greatest combos. Such a binary flag should elegantly cover both kernel module and portage tree type use cases, by indicating to ZFBootMenu that the dataset in question (and snapshots thereof) provide system-integrity critical system state and should be paired with a root dataset selection. ZFSBootMenu could then make appropriate assumptions around default selections / temporally proximal pairings.
A second idea is a ZFS dataset property "zfsbootmenu-last-successful-boot" = "<datetime>" which combined with snapshot times should provide a useful inference. This could be rolled in to the ZFSBootMenu userland as an rc script updating the property on boot. Additional information such as "zfsbootmenu-last-successful-boot-options" and "zfsbootmenu-last-successful-boot-dataset-<dataset>-snapshot" could then be added. Alternatively or in addition a zfsbootmenu dataset could be added with more detailed log files.
The result should be a cross-distribution (indeed cross-OS) methodology for the autonomous inference and validation of boot configurations involving multiple datasets in all use cases, a plethora of debugging information in a standard location, and even a mechanism to iteratively and autonomously fall back toward a functional boot configuration in the event of problems (which may be further improved using watchdog drivers, ie. if boot does not complete in X minutes, reboot and try another configuration).
This wouldn't apply if you needed to have divergent state though, though it's hard to imagine a use case for that unhandled by fs snapshots.
I'm actually thinking of going the other way, from NixOS to Void+ZFS. I've been using NixOS on 2 machines for a few months now, so I'm relatively new to it, but I still struggle with basic things, and don't really grok the Nix language. If ZFS+ZFSBootMenu can give me easy snapshotting and rollback functionality, then I might prefer it over NixOS.
Sure, Nix does many more things besides snapshots, but for my use case it's the main benefit, so I wouldn't be missing much.
So if I want to switch from pulse to pipewire, or some other messy change, I just edit the config, boot into it and it's like pulse never existed. If I don't like pipewire (I love pipewire) then I just choose the prior config option at boot and equally, pipewire never existed.
I don't want my bootloader handling snapshots of my homedir, I can do that myself if I need (zfs auto snapshots, etc.). So with an ephemeral root, there is no other state to manage, making this kind of boot menu redundant.
Think of it this way, you can carefully manage filesystem state using snapshots, or you can slap it all in the /nix store and have your system live assemble itself to spec on every boot. Like using git for your source tree instead of tar'ing up the whole thing everytime you make a scary change.
Yes, Nix manages a history of past system instances and NixOS modifies the bootloader to present each of these states as a bootable option. This maps loosely to the ability to elevate ZFS snapshots to boot environments in ZBM, but the functionality is not redundant. In fact, it isn't even a compatible alternative---we haven't found a good way to make ZBM boot NixOS. If you want NixOS, you're booting the NixOS way.
Nix is a very interesting concept that offers several advantages. It also has drawbacks. For example, it can be inordinately complex to manage small deviations from upstream configurations that aren't represented by pre-existing options. (Ever try to add a single line to a PAM configuration file in Nix?)
The Nix way of booting falls apart should you want to have multiple Linux distributions coexisting on a single pool. NixOS works best when you have complete buy-in. ZFSBootMenu doesn't care; if it can find kernels in the `/boot` directory of a ZFS filesystem, it will show you the filesystem and let you boot it.
Timeshift
> System restore tool for Linux. Creates filesystem snapshots using rsync+hardlinks, or BTRFS snapshots. Supports scheduled snapshots, multiple backup levels, and exclude filters. Snapshots can be restored while system is running or from Live CD/USB.
I will wait ...
The same setup is possible on all Linux distros but the user has to set it up.
Nope.
Cite from System Recovery and Snapshot Management with Snapper for OpenSUSE Linux.
● Limitations
A complete system rollback, restoring the complete system to the identical state as it was in when a snapshot was taken, is not possible.
With ZFS Boot Environments you are bulletproof.
With btrfs+snapper you are crossing fingers if it will work the way you need.
Not the same thing.