Given that /boot on Fedora is by default an ext4 partition, this makes BTRFS snapshots on Fedora a not so smooth experience. If you restore a snapshot you may have trouble with kernels due to /boot not being restored.
Last time I restored a BTRFS snapshot, I was dropped into an emergency shell. To fix this, I had to boot from an older kernel and run updates.
My idea is not complicated: Use rsync to backup the contents of /boot and restore it so no kernel trouble upon restore while keeping the advantages of btrfs.
So given a disk layout like mine:
nvme0n1 259:0 0 232.9G 0 disk
├─nvme0n1p1 259:1 0 600M 0 part /boot/efi
├─nvme0n1p2 259:2 0 1G 0 part /boot
└─nvme0n1p3 259:3 0 231.3G 0 part
└─luks-<uuid> 253:0 0 231.3G 0 crypt /home
The backup of /boot will be either on a separate subvolume or on the /boot partition in a specific folder.
What are your thoughts? (I hope this is the correct place to ask, or should I move this somewhere else?)
I think restoring/fixing the boot and/or efi partitions (maybe even the firmware entries) should all be a part of whatever script or process you use to rollback Btrfs. Just my two cents.
I think you should be able to run something like KERN=$(ls -v /lib/modules | tail -n 1); kernel-install add $KERN /lib/modules/$KERN/vmlinuz after your Btrfs rollback rather than keeping another copy of everything in another directory. You’d just need to make that part of your rollback script.
Since Fedora keeps multiple kernel versions around, is this something you are having problems with in practice? If so, it seems easier to increase the number of kernels fedora keeps by default unless you restore very old btrfs root snapshots.
Yeah. Sorry, you would have to use chroot. So it would be a little more complicated if you wanted to restore things that way. But everything you need should already be present. You shouldn’t need to maintain another copy of things. Also, before you chroot, I think you would need to run something like mount --rbind <path-to-current-boot> <path-to-boot-under-snapshot> (and you might need/want to bind mount a few other things like /proc as well). The kernel-install ... command will create the /boot/loader/entries/*.conf files (i.e. the grub menu entries). But you’d probably want to delete the old ones first and then re-create all the ones that are available under your snapshot with something like:
for KERN in /lib/modules/*/vmlinuz; do
kernel-install add $(cut -d '/' -f 4 <<< $KERN) $KERN
Note that none of this is tested. I do something sort of similar. But I use ZFS for my root filesystem and I use only one partition for my kernels, initramfses, and bootloader (systemd-boot). So my system is quite different.
Yes. That should work as long as the rollback isn’t too far. If the rollback is too far, the corresponding kernel modules under /lib/modules/<kernel-version> might not be present. Most of the time, people probably won’t want/need to roll their system back that far though. And increasing the number of older kernels that you keep on your boot partition just in case isn’t a bad idea either.