Configuring BTRFS mirror (RAID1) on Proxmox 8.3 root partition

31 March 2025

BTRFS mirror (RAID1) is available as a "technical preview" in Proxmox 8. We'll be doing this chiefly due to ZFS traditionally chewing through consumer-grade solid state drives. Additionally, today we're using a JetWay JBC375F533W industrial PC, which boasts an unimpressive Intel Celeron J1900 4-threads running at 1.99GHz and 4GB of soldered RAM, so we're looking to use minimal resources on our base system.

EFI partition sync

Proxmox installer does not configure proxmox-boot-tool to keep EFI partitions in sync as it would with a ZFS mirror, we have to do that manually.

Cleanup

Unmount partition

First, we'll unmount the EFI partition with:

umount /boot/efi

Edit fstab

Next, we'll open /etc/fstab in an editor and comment out the line for the /boot/efi mountpoint.

Reload systemd

When that's finished, reload systemd using:

systemctl daemon-reload

This will regenerate the systemd mount files.

Sync

We are going to assume the disks we want to keep in sync are /dev/sda and /dev/sdb.

Remove EFI boot targets

To make sure everything syncs correctly, we're going to remove all the EFI boot targets using efibootmgr. Use the help menu to do that as each computer assigns boot numbers differently. Yours may also contain other boot options that should also be removed.

Format partitions

Format the EFI system partitions:

proxmox-boot-tool format /dev/sda2 --force
proxmox-boot-tool format /dev/sdb2 --force

Initialize bootloader

systemd-boot

If the server does not use Secure Boot, you can use systemd-boot: 

proxmox-boot-tool init /dev/sda2
proxmox-boot-tool init /dev/sdb2
GRUB

If the server uses Secure Boot, you must use GRUB:

proxmox-boot-tool init /dev/sda2 grub
proxmox-boot-tool init /dev/sdb2 grub

proxmox-boot-tool replaces the firmware boot menu option for GRUB on /dev/sda2 with /dev/sdb2 instead of adding a second option. We'll add the /dev/sda2 menu option back ourselves here:

efibootmgr --create --disk /dev/sda --part 2 --label "proxmox" --loader "\EFI\proxmox\shimx64.efi"

This is only required with GRUB; proxmox-boot-tool configures systemd-boot as expected.

Boot degraded

ESP partition sync is only half the battle. A BTRFS mirror will keep a system running in the event of a drive failure, however a degraded array requires manual intervention to boot unless a kernel flag is set.

systemd-boot

To add the kernel flag to systemd-boot, first we're going to copy the running kernel flags into a new file /etc/kernel/cmdline:

cat /proc/cmdline | sed 's/BOOT_IMAGE=.* root=/root=/' > /etc/kernel/cmdline

Now we'll open /etc/kernel/cmdline in our favourite editor and add rootflags=degraded at the end of the line, ensuring everything remains on a single line. It should look similar to this unless you've added addition boot flags, with root= being your root filesystem UUID:

root=UUID=8e05295b-7df8-465c-9d42-d44fb934e75f ro quiet rootflags=degraded

If it has initramfs=, remove it.

grub

Now we'll open /etc/default/grub in our favourite editor and add rootflags=degraded to GRUB_CMDLINE_LINUX_DEFAULT. It should look similar to this unless you've added addition boot flags:

GRUB_CMDLINE_LINUX_DEFAULT="quiet rootflags=degraded"

Once that's done, we resync the boot partitions:

proxmox-boot-tool refresh

And Bob's your uncle.

Reboot to confirm it boots as expected:

reboot now

Final thoughts

Due to it's underwhelming amount of RAM, we'll need swap space. Similar to ZFS, BTRFS does not support swap files. In a future post, we'll use mdadm to create a mirrored partition for use as swap space.

If you split the swap, a failed drive will definitely result in data loss.

Additionally, and far beyond any recommended use case, we'll later be using part of each drive as a Ceph OSD.