Safe way to move /boot to the root BTRFS partition to use snapper?

Hi,

I have been using a custom install of Debian for some time with a BTRFS root partition and timeshift for system-wide snapshots. I do not use grub integration to boot from snapshots but have many times rolled back to a previous system after experimenting or experiencing issues. It is very powerful to be able to create a “known good” snapshot before making major changes or installing new stuff - and then be able to roll back if something breaks :sunglasses:

I would like to be able to do the same with my Fedora 40 KDE installation (using snapper instead of timeshift because of naming conventions), but I would like the /boot partition to be part of the root snapshots.

Of course backup important files and be prepared to end up doing a complete reinstall if things go south… :smile:

I believe the steps would be something like this - while booted from a live USB:

  • temporarily mount the root partition and the boot partition and copy the contents of the boot partition to the /boot directory within the BTFS root partition
  • update /etc/fstab on the root partition to not mount the EXT4 /boot partition
  • mount the EFI partition under the /boot/efi directory
  • do some chroot magic and reinstall the grub boot manager - then cross fingers and reboot

Are these steps correct - and what are the details of the last step?

Next I would assume, I can make configurations for snapper on the / and /home subvolumes and create snapshots and rollback safely when needed, as I have done with my Debian installs?

/Jaybe

(P.S. Any plans to enable something like this in F41 or F42?)

1 Like

Added f40

Note that it may be possible to have /boot in the btrfs file system.
Doing so means that grub must be able to read btrfs which it may not be able to do. The kernel and intramfs are both in /boot so configuring it is problematic and not standard. Grub at least must be able to read btrfs in order to load the kernel.

Maybe look at using systemd-boot which appears to put the kernel and initramfs files into the efi partition instead.

Its grub that reads the /boot not the UEFI BIOS.
The UEFI BIOS reads the EFI partition that is usualy mounted under /boot/efi.

1 Like

I don’t think you don’t need to be on a live USB to mess with /boot

I also don’t think that grub has to be reinstalled for this.

I would test in a VM first but I would try this:

  • Unmount /boot/efi
  • Unmount /boot
  • Mount the boot partition at /mnt/boot
  • Copy everything from /mnt/boot to /boot
  • Remount /boot/efi
  • Comment out the entry in /etc/fstab for /boot
  • Rebuild your initrams with dracut
  • Rebuild your grub config file

I would recommend trying this in a VM before you mess with your real system.

EDIT: Added changing fstab and rebuilding initrams

1 Like

Added btrfs, grub and removed kde

Thanks, @dalto :+1: I did this in a newly installed Fedora 40 KDE VM:

# umount /boot/efi
# umount /boot
# mkdir /mnt/boot
# mount /dev/vda2 /mnt/boot
# cd /mnt/boot
# rsync -a * .* /boot/
# mount /boot/efi
# vi /etc/fstab
# dracut -f
# grub2-mkconfig -o /boot/grub2/grub.cfg

…and it seems to have worked!

Will do some snapper experiments in the VM before committing to my main system, but so far so good :smile:

/Jaybe

4 Likes

You are right. I edited that above.