Occasion:
Like my one mentioned in the zfs boot thread my intention was to use BTRFS as root filesystem because the resource finger print is smaller. While my testing time for this thread some negative experiences with BTRFS comes up, but nevertheless my one would prefer btrfs over zfs for rootfs. This solution combines the tools snapper, grub-btrfs and overlayroot (optional). There are many btrfs snapshot tools for the "easy way" out there, but for production server the best is snapper from my point of view. What my one dont need to mention is that a BTRFS Raid 1 solution with my demands your one cant find in the internet already.
Table of Contents:
1. My goals for this implementation:

2. Troubles while creation
3. Requirements:
A normal PVE 8 or 9 BTRFS (Raid1) installation. The PVE install disks are sda and sdb.
4. Configuration steps necessary 4 both Bios or UEFI boot:
5. UEFI install
7. Rollback possibilities
With this solution it does`nt matter if the system is already booted into the wanted sapshot or not. One can rollback in both situations. The only difference is that if one is still logged in the old subvolume one have to give the command "update-grub" after reboot into the target snapshot.
8. Back to proxmox-boot environment from UEFI
For a PVE 8 installation this solution changed only the path for the grub environment variable "prefix". So nothing must changed back.
9. Back to proxmox-boot environment from Bios
For a PVE 8 installation this solution changed only the path for the grub environment variable "prefix". So nothing must changed back.
10. Sources
Like my one mentioned in the zfs boot thread my intention was to use BTRFS as root filesystem because the resource finger print is smaller. While my testing time for this thread some negative experiences with BTRFS comes up, but nevertheless my one would prefer btrfs over zfs for rootfs. This solution combines the tools snapper, grub-btrfs and overlayroot (optional). There are many btrfs snapshot tools for the "easy way" out there, but for production server the best is snapper from my point of view. What my one dont need to mention is that a BTRFS Raid 1 solution with my demands your one cant find in the internet already.
Table of Contents:
- My goals for this implementation
- Troubles while creation
- Requirements
- Configuration steps necessary 4 both Bios or UEFI boot
- UEFI install
- BIOS install
- Rollback possibilities
- Back to proxmox-boot environment from UEFI
- Back to proxmox-boot environment from Bios
- Sources
1. My goals for this implementation:
- as little change as possible to the original installation
- changes to new bootloader are based of a PVE ISO standard installation
- in a few steps back to the original PVE boot environment
- kernel image files stored on the root partition for snapshoting
- kernel pinning possible
- easy snapshot rollback, also when OS does not boot anymore
- snapshot boot menu
- MemTest im Bootmenu available
- system boots even if one drive is offline
- GRUB is used for all boot combinations except no loader is needed

2. Troubles while creation
- snapper creates only readonly snapshots
- this produces 2 problems when booting in a snapshot: the first is that pve services could not start error free, so a temporary test run is not possible; the second is that if one wants to execute "update-grub" directly after roolback this is not possible
- SOLUTION: using a subvolume "@grub" for /boot/grub and the debian packet "overlayroot"
- snapper create a subvolume /.snapshots as targets for its snapshots per default
- btrfs excludes subvolumes in its snapshots, so when one boots into a snapshot for rolling back or boots a rolled back snapshot, snapper is not able to access its snapshots anymore
- SOLUTION: use mountpoint /.snapshots for snapshots subvolume
- GRUBs environment variable "prefix" for grub.cfg is hardcoded at grub-install time
- that means: when one boot into a rolled back snapshot and change the grub.cfg the changes are not visible because GRUB looks still to the filesystem path from where it was installed
- SOLUTION: using a subvolume "@grub" for /boot/grub
- PVE 8 installation with UEFI configure a mountpoint for sda2 in fstab
- this goals in a boot error when try to boot a degraded raid
- SOLUTION: comment out this fstab entry
- PVE default installation does'nt set mount option "degraded" for "/" nor kernel parameter
- your system will run into a early boot error when its degraded (one disk offline)
- My one posted a bug to Proxmox, therefor they can add this parameter for a next big release. The reaction of Proxmox was the nonsensical my one ever read in a IT thread. Proxmox answered that to use this parameter is dangerous because btrfs does'nt offer an integrated notification service like zfs does. So my one suggest to eliminate the btrfs raid1 option in the installation wizard because it makes no sense when one can not reboot with a raid error. The bugzilla post was deactivated or deleted. One cant find it anymore.
- SOLUTION: add parameter "degraded" to fstab and kernel call
- My research revealed a raid1 error with actual kernels that booting several times into a degraded raid 1 can set the btrfs filesystem to readonly. My tests with PVE 9 showed no problem with that but my one noticed that the command "update-grub" does not function anymore. So this is, of course, no production ready state although debian have been tagged btrfs raid 1 as stable for years. My opinion is that everyone have to decide for his one whether to use btrfs as root filesystem or not. To combine mdadm raid with btrfs is less useful than using zfs.
3. Requirements:
A normal PVE 8 or 9 BTRFS (Raid1) installation. The PVE install disks are sda and sdb.
4. Configuration steps necessary 4 both Bios or UEFI boot:
- create nesseccary subvolumes
btrfs subvolume snapshot / /@rootfsbtrfs subvolume create /@snapshotsbtrfs subvolume create /@grub- make rootfs to the default subvolume to boot from
btrfs su sh /@rootfsbtrfs subvolume set-default [ID] /- change fstab to the new layout (ATTENTION: line for /.snapshots and ESP mount is comment out)
nano /@rootfs/etc/fstabUUID=722b146c-d11f-48dd-91c4-a4448792041f / btrfs subvol=@rootfs,defaults,degraded,compress 0 1#UUID=722b146c-d11f-48dd-91c4-a4448792041f /.snapshots btrfs subvol=@snapshots,defaults,compress 0 1UUID=722b146c-d11f-48dd-91c4-a4448792041f /boot/grub btrfs subvol=@grub,defaults,compress 0 1#UUID=CEA1-7F15 /boot/efi vfat defaults 0 1- send content from grub to new subvolume
mv /@rootfs/boot/grub/* /@grub/- copy local-btrfs to new location
rmdir /@rootfs/var/lib/pve/local-btrfsbtrfs su sn /var/lib/pve/local-btrfs /@rootfs/var/lib/pve/local-btrfsbtrfs su de /var/lib/pve/local-btrfs- set "degraded" to kernel command line
nano /@rootfs/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="rootflags=degraded"- reboot your system
- delete old rootfs data of subvolid=5
mkdir /mnt/btrfsrootmount -o subvolid=5 /dev/sda3 /mnt/btrfsrootcd /mnt/btrfsrootshopt -s extglobrm -rf !(@*)shopt -u extglobcd /- install addional packets
apt update && apt install build-essential git inotify-tools snapper overlayroot- configure snapper to your needs
snapper -c root create-config /btrfs su delete /.snapshotsmkdir /.snapshotsnano /etc/snapper/configs/rootnano /etc/default/snapper- comment in line with "/.snapshots" in fstab
- install grub-btrfs
git clone https://github.com/Antynea/grub-btrfs.gitcd grub-btrfsmake installsystemctl enable grub-btrfsd- configure grub-btrfs to your needs
nano /etc/default/grub-btrfs/configGRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@rootfs")- [optional] configure overlayroot
nano /etc/default/grub-btrfs/configGRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="overlayroot=tmpfs:recurse=0"5. UEFI install
1. Configuration steps necessary 4 both PVE 8 + 9
mkdir /boot/efi/sda2mkdir /boot/efi/sdb2mount /dev/sda2 /boot/efi/sda2mount /dev/sda2 /boot/efi/sda22. only for PVE 9
- delete ESP-UUIDs in proxmox-boot-uuids file
true > /etc/kernel/proxmox-boot-uuids- install grub
grub-install.real --efi-directory=/boot/efi/sda2 --bootloader-id=grub-sda /dev/sda2grub-install.real --efi-directory=/boot/efi/sdb2 --bootloader-id=grub-sdb /dev/sdb2update-grub- make new grub entries to the default Bootloader, when all UEFI profiles are cleared
cp /boot/efi/sda2/EFI/grub-sda/* /boot/efi/sda2/EFI/BOOT/cp /boot/efi/sda2/EFI/grub-sda/grubx64.efi /boot/efi/sda2/EFI/BOOT/BOOTx64.EFIcp /boot/efi/sdb2/EFI/grub-sdb/* /boot/efi/sdb2/EFI/BOOT/cp /boot/efi/sdb2/EFI/grub-sdb/grubx64.efi /boot/efi/sdb2/EFI/BOOT/BOOTx64.EFI3. only for PVE 8
- change grub variable "prefix" in grub.cfg on both ESPs
nano /boot/efi/sda2/EFI/proxmox/grub.cfgnano /boot/efi/sdb2/EFI/proxmox/grub.cfg
set prefix=($root)'/@grub'- update grub-menu
update-grub
6. BIOS install- [only PVE 9] delete ESP-UUIDs in proxmox-boot-uuids file
true > /etc/kernel/proxmox-boot-uuids- install grub
grub-install.real /dev/sdagrub-install.real /dev/sdb- update grub-menu
update-grub7. Rollback possibilities
With this solution it does`nt matter if the system is already booted into the wanted sapshot or not. One can rollback in both situations. The only difference is that if one is still logged in the old subvolume one have to give the command "update-grub" after reboot into the target snapshot.
1.
snapper -a classic rollback [id des snapshots]2.
update-grub8. Back to proxmox-boot environment from UEFI
For a PVE 8 installation this solution changed only the path for the grub environment variable "prefix". So nothing must changed back.
For PVE 9
- readd ESP UUIDs in /etc/kernel/proxmox-boot-uuids; one find them with "blkid"
nano /etc/kernel/proxmox-boot-uuids- deactivate the both grub UEFI entries; one find the IDs in the 1. column from the output of command "efibootmgr"
efibootmgr -Ab [ID grub-sda]efibootmgr -Ab [ID grub-sdb]- copy systemd efi file back to standard BOOT
mount /dev/sda2 /boot/efi/sda2mount /dev/sda2 /boot/efi/sda2cp /boot/efi/sda2/EFI/systemd/systemd-bootx64.efi /boot/efi/sda2/EFI/BOOT/BOOTX64.EFIcp /boot/efi/sdb2/EFI/systemd/systemd-bootx64.efi /boot/efi/sdb2/EFI/BOOT/BOOTX64.EFI9. Back to proxmox-boot environment from Bios
For a PVE 8 installation this solution changed only the path for the grub environment variable "prefix". So nothing must changed back.
For PVE 9
- readd ESP UUIDs in /etc/kernel/proxmox-boot-uuids; one find them with "blkid"
nano /etc/kernel/proxmox-boot-uuids- initialize the grub environement new
proxmox-boot-tool reinit10. Sources
- https://wiki.ubuntuusers.de/GRUB_2/Konfiguration/
- https://www.kubuntuforums.net/forum...nstall-to-a-subvolume-install-in-4-easy-steps
- https://github.com/david-cortes/snapper-in-debian-guide
- https://wiki.archlinux.org/title/Snapper#
- https://rex.writeas.com/use-overlay-filesystem-on-ubuntu
- https://spin.atomicobject.com/protecting-ubuntu-root-filesystem/
- https://wiki.ubuntuusers.de/GRUB-Umgebung_analysieren/
- https://wiki.ubuntuusers.de/GRUB_2/Konfiguration/
- https://wiki.ubuntuusers.de/GRUB_2/Shell
Last edited: