I believe I found a simple bug in GRUB that prevents me from booting a BTRFS 
Raid 1 if one of the devices is missing.

I believe the error is in grub_find_root_devices_from_btrfs from the file 
osdep/linux/getroot.c:
A call to  BTRFS_IOC_DEV_INFO that returns -ENODEV  should not fail the entire 
function.  I think it should continue on to look for other device ids.

In my case, I have a total 2 devices at device ids 2 and 3.  This is because I 
removed a previous device from my raid.

The call to BTRFS_IOC_FS_INFO on my system returns:
max_id=3
num_device=2

Because grub_find_root_devices_from_btrfs returns a failure,  
grub_find_root_devices_from_mountinfo falls back to code that only detects one 
drive on my BTRFS Raid 1.

This results in grub-probe only listing one device, which causes grub-mkconfig 
to only generate one device for the search command in grub.cfg.
This also results in grub-install using only one device for the prefix in the 
call to grub-mkimage. This prevents booting if that device is not available, 
but the mirror is.

Before I removed device_id =1, grub-probe returned all devices

Current Results (Only returns one, should be two):

$ sudo grub-probe /boot/grub -t device
/dev/mapper/VG_BTRFS2-LV_BOOT2

$ sudo grub-probe /boot/grub -t bios_hints
lvmid/gEfhOx-J9hr-8tkA-OgjD-Aqqu-XR2T-sFB4me/oNnMDp-Rit5-P0qs-QZlf-bQQe-tZU7-Wwmz8z

Info:
Kernel:  4.15.0-12-generic #13-Ubuntu SMP (based on 4.15.7 mainline)
btrfs-progs: 4.15.1-1
Grub:  2.02~beta2-36ubuntu3.17

$ btrfs fi show
Label: none  uuid: 84c8e78b-9d7f-4451-966d-3c25154e89b8
        Total devices 2 FS bytes used 22.16GiB
        devid    2 size 100.00GiB used 25.03GiB path 
/dev/mapper/VG_BTRFS2-LV_ROOT2
        devid    3 size 100.00GiB used 25.03GiB path 
/dev/mapper/VG_BTRFS3-LV_ROOT3


Label: none  uuid: 059ab98f-eb63-471d-b099-6561baf39040
        Total devices 2 FS bytes used 61.04GiB
        devid    2 size 200.00GiB used 62.03GiB path 
/dev/mapper/VG_BTRFS2-LV_HOME2
        devid    3 size 200.00GiB used 62.03GiB path 
/dev/mapper/VG_BTRFS3-LV_HOME3


Label: none  uuid: ffe8b1a0-030c-42c2-94f5-b7e8e54b1439
        Total devices 2 FS bytes used 342.04MiB
        devid    2 size 1.00GiB used 693.62MiB path 
/dev/mapper/VG_BTRFS2-LV_BOOT2
        devid    3 size 1.00GiB used 693.62MiB path 
/dev/mapper/VG_BTRFS3-LV_BOOT3


Since this is my first time sending to this mailing list, please let me know if 
you need more information, or if there is a better place to post this.

Thanks,
Matt Hawn

_______________________________________________
Bug-grub mailing list
Bug-grub@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-grub

Reply via email to