Boot from btrfs RAID5/6?

0

I'm trying to build an Arch Linux system with a btrfs RAID5/6 root. When I install GRUB on one of the volume's disks, it prints a message like this on startup:

error: no such device: [my btrfs volume uuid]

…and then dumps me into a recovery shell. If I type ls (hdX) (where X is one of the volume's physical disks, it prints some error text including this:

Unsupported raid flags 82

A few forum threads suggest that GRUB doesn't doesn't support these kinds of btrfs volumes right now. So, my next thought was to create a separate ext4-formatted boot drive. I started from an Arch live CD and did this:

$ mount /dev/sdb /mnt # one of the btrfs RAID5 disks
$ arch-chroot /mnt/root /bin/bash
$ mkfs.ext4 /dev/sdi # our new boot disk
$ mount /dev/sdi /mnt # /mnt inside the chroot
$ grub-install --target=i386-pc --root-directory=/mnt /dev/sdi
$ grub-mkconfig -o /mnt/boot/grub/grub.cfg
$ umount /mnt
$ exit # …the chroot
$ reboot # …and switch the boot drive in BIOS settings

I successfully landed in GRUB, but got these messages after the menu timeout:

error: no such device: [my btrfs volume uuid]
Loading Linux linux ...
error: hd6 cannot get C/H/S values.
Loading initial ramdisk ...
error: you need to load the kernel first.

Press any key to continue...

…then I was dumped back into the GRUB menu. I'm trying to find answers to two questions:

  1. Am I doing something wrong in creating my bootstrap volume?
  2. Is there another, better way to boot my system from the btrfs RAID?

s4y

Posted 2016-06-06T02:36:50.063

Reputation: 3 469

You can try using a separate boot partition (BIOS) or putting all your boot stuff in your esp partition (EFI). – whoKnows – 2019-04-12T13:04:29.340

Answers

1

Gentoo on my home server boots from a single-drive Btrfs which I created like this (though the custom options should be irrelevant and the complete installation obviously required a lot more steps in between these relevant lines):

mkfs.btrfs -f -s 4k -n 4k -O extref,skinny-metadata,no-holes /dev/sda
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

and it has these fstab entries:

/dev/sda   /            btrfs    noatime,autodefrag              0 0
/dev/sdb   /            btrfs    noatime,autodefrag              0 0

The user data is stored on a RAID5 Btrfs filesystem consisting of 3x4Tb drives (sdb,sdc,sdd).

I think I might hit two limitations at once when I want to move the system root to the large RAID5 filesystem:

  • GRUB2 (as of 2.02_beta3) doesn't seem to support Btrfs RAID5 (I tried that in a virtual machine with 20Gb virtual drivers and got the same errors as you did)
  • EFI boot requires GPT partitioning and FAT16 or FAT32 filesystem for the bootloader while legacy BIOS boot requires <=2Tb space addressed by the MBR (I am not entirely sure about this [applicable workarounds might exist] but I think it applies for >2Tb drivers/volumes even if we don't have actual partitions because from the MBR's perspective our whole LBA space on the drive is technically a single basic partition and I think we still have a standard MBR in the filesystem's "MBR hole" to make BIOS loading GRUB). Although, I didn't try to test this in a VM after my test above failed anyway.

János Tóth F.

Posted 2016-06-06T02:36:50.063

Reputation: 11