Booting with Rockstor installed on btrfs raid

The install completes but the system is unable to boot and comes up with a open_ctree failed with an initrd shell. This usually happens when you install with a btrfs handled raid (not a mdadm handled one). You may get the occasional boot success, but the root issue is that one or both disks are not initialised fully by btrfs before the kernel tries to mount the fs.

There are two ways to fix this. The second is the fastest, safest, easiest way :smiley:

The fix is to append boot commands such as

rootflags=device=/dev/sda2,device=/dev/sdb2,rootfstype=btrfs

or

rootflags=device=/dev/disk/by-partuuid/6dc5624c-2d54-4726-b2fa-a7a988d337a4,device=/dev/disk/by-partuuid/b57f2240-fa2e-4516-9049-603d2c5029b5,rootfstype=btrfs

to the grub entry or GRUB_CMD in /etc/default/grub. This really needs to be done on install.

(I also had to remove the existing rootflags=).

—edit—
It seems that all that is required is for btrfs device scan to be run in the initrd on boot.

Steps to fix new install

NOTE: I have not tried this with /boot on the root partition, only on a separate partition. I imagine booting from a btrfs raid setup may not actually work. In fact the Oracle website recommends the partitioning below too.

Partitions required

Single partitions

Preferably on a single disk but you can put these on the two disk system; you will need to mirror the partition setup however to help keep things consistent.

  1. /boot/efi, EFI type, can be small (50mb)
  2. /boot, 200mb at least, this is the minimum size for two kernels

Raid partitions

  1. a swap partition, preferably set up as raid 1 through the GUI
  2. the remainder of space can be simply selected as BTRFS type, and given the / mount point

An alternative is to have / sized and separate from the remaining disk space - you seem to only need 3GiB.

Once the install is done, don’t reboot yet. Ctrl+Alt+F2 to a terminal then:

  1. chroot /mnt/sysimage,
  2. lsblk to see which parts are mounted - the part at / will have a matching part on the other disk. btrfs doesn’t mount both, but uses them both internally.
  3. blkid will show you the matching partition of the btrfs raid, the two partitions will have the same UUID
  4. blkid |grep /dev/sd[part of / ] >> /etc/default/grub
  5. blkid |grep /dev/sd[matching of / ] >> /etc/default/grub (these two steps are to make editing the grub easier)
  6. vi /etc/default/grub

You will have lines similar to

/dev/sda2: LABEL="rockstor" UUID="54dcbbf3-1fe0-4b56-befc-8b275120c872" UUID_SUB="8a191f4c-7a12-4d33-ab9c-156ad72598ec" TYPE="btrfs" PARTUUID="0c6cc0a6-d19a-4884-938a-41516ebb4f74"
/dev/sdb2: LABEL="rockstor" UUID="54dcbbf3-1fe0-4b56-befc-8b275120c872" UUID_SUB="ab092784-25cc-474a-8967-52316c790b06" TYPE="btrfs" PARTUUID="a5516130-605f-4d70-83aa-5c159380df77" 

at the end of the file for referencing. Change the existing GRUB_CMDLINE_LINUX= to GRUB_CMDLINE_LINUX_DEFAULT= and add a new GRUB_CMDLINE_LINUX= below. The contents of this line will need to contain references to the PARTUUID of the partitions. This is where your ace ViM skills will come in handy:

GRUB_CMDLINE_LINUX="rootflags=device=/dev/disk/by-partuuid/0c6cc0a6-d19a-4884-938a-41516ebb4f74,device=/dev/disk/by-partuuid/a5516130-605f-4d70-83aa-5c159380df77,subvol=root rootfstype=btrfs"

And don’t forget to delete the reference lines at the end before you save.

  1. grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
  2. reboot
  3. Enjoy a nice, fast btrfs powered raided NAS.

Better way to fix boot

As above, install, but don’t reboot. Get to console chroot and then;

  1. rm /opt/rockstor/conf/64-btrfs.rules
  2. cp /usr/lib/udev/rules.d/64-btrfs.rules /etc/udev/rules.d/
  3. dracut -fv
  4. reboot.

@luke Nice post. And thanks for transferring it from your original GitHub issue.
Linking for context:


and in turn to @ghensley’s issue on udev alterations sighted in yours:

Was a bit half-alseep when I did the post sorry, should have linked in the issues.

No worries on that one. I’m just trying to tie together what threads we have as we go, otherwise it can all get quite mixed up and we end up duplicating each others efforts which is always a shame and can be discouraging going forward.

1 Like