Dual Boot problem with GRUB and BTRFS

Hello! On my PC, I have installed the main distro EndeavourOS on BTRFS, with /home on ext4, Windows 10 on NTFS, and one partition dedicated for testing different distributions. The current testing distro is Archcraft Linux. Initially, when I installed Archcraft Linux on ext4, there were no issues - os-prober in EndeavourOS could detect it, and there were no problems with GRUB.

However, when I attempted a new installation of Archcraft Linux on BTRFS, EndeavourOS’s GRUB could no longer detect it. Only EndeavourOS and Windows 10 were visible. The same issue occurred when using Archcraft’s GRUB - it couldn’t detect EndeavourOS.

I found that if I mount Archcraft in fstab with the subvol parameter set to subvol=/@, os-prober was able to detect Archcraft. However, attempting to boot into Archcraft from GRUB resulted in an error.

error: file '/boot/vmlinuz-linux' not found.

And this is my FSTAB file:

UUID=7071-6531                            /boot/efi      vfat    fmask=0137,dmask=0027 0 2
UUID=6cff14c5-7e99-4a74-8820-818469c758e9 /              btrfs   subvol=/@,noatime,compress=zstd 0 0
UUID=6cff14c5-7e99-4a74-8820-818469c758e9 /var/cache     btrfs   subvol=/@cache,noatime,compress=zstd 0 0
UUID=6cff14c5-7e99-4a74-8820-818469c758e9 /var/log       btrfs   subvol=/@log,noatime,compress=zstd 0 0
UUID=5957b196-c33b-40d9-b083-1acac555be6f /home          ext4    noatime    0 2
UUID=F8D005A1D00566EA                     /media/data    ntfs    noatime    0 2
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
UUID=e25f324f-adb1-49f2-81b2-324d092b3ce8 /media/archcraft btrfs subvol=/@ 0 0

This is the section in my grub.cfg file that pertains to Archcraft:

menuentry 'Archcraft (rolling) (on /dev/nvme0n1p5)' --class archcraft --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-e25f324f-adb1-49f2-81b2-324d092b3ce8' {
	insmod part_gpt
	insmod btrfs
	search --no-floppy --fs-uuid --set=root e25f324f-adb1-49f2-81b2-324d092b3ce8
	linux /boot/vmlinuz-linux root=/dev/nvme0n1p5
	initrd /boot/initramfs-linux.img
}
submenu 'Advanced options for Archcraft (rolling) (on /dev/nvme0n1p5)' $menuentry_id_option 'osprober-gnulinux-advanced-e25f324f-adb1-49f2-81b2-324d092b3ce8' {
	menuentry 'Archcraft (rolling) (on /dev/nvme0n1p5)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-linux--e25f324f-adb1-49f2-81b2-324d092b3ce8' {
		insmod part_gpt
		insmod btrfs
		search --no-floppy --fs-uuid --set=root e25f324f-adb1-49f2-81b2-324d092b3ce8
		linux /boot/vmlinuz-linux root=/dev/nvme0n1p5
		initrd /boot/initramfs-linux.img
	}
}

Now if I manually (hard code) add these lines to grub.cfg (taken from the original Archcraft grub.cfg:

menuentry 'Archcraft Linux' --class archcraft --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-e25f324f-adb1-49f2-81b2-324d092b3ce8' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod btrfs
	search --no-floppy --fs-uuid --set=root e25f324f-adb1-49f2-81b2-324d092b3ce8
	linux	/@/boot/vmlinuz-linux root=UUID=e25f324f-adb1-49f2-81b2-324d092b3ce8 rw rootflags=subvol=@  quiet splash loglevel=3 udev.log_level=3 vt.global_cursor_default=0 splash
	initrd	/@/boot/initramfs-linux.img
}
submenu 'Advanced options for Archcraft Linux' --class recovery $menuentry_id_option 'gnulinux-advanced-e25f324f-adb1-49f2-81b2-324d092b3ce8' {
	menuentry 'Archcraft Linux, with Kernel: linux' --class archcraft --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-e25f324f-adb1-49f2-81b2-324d092b3ce8' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		search --no-floppy --fs-uuid --set=root e25f324f-adb1-49f2-81b2-324d092b3ce8
		linux	/@/boot/vmlinuz-linux root=UUID=e25f324f-adb1-49f2-81b2-324d092b3ce8 rw rootflags=subvol=@  quiet splash loglevel=3 udev.log_level=3 vt.global_cursor_default=0 splash
		initrd	/@/boot/initramfs-linux.img
	}
	menuentry 'Archcraft Linux, with Kernel: linux (fallback initramfs)' --class archcraft --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-e25f324f-adb1-49f2-81b2-324d092b3ce8' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		search --no-floppy --fs-uuid --set=root e25f324f-adb1-49f2-81b2-324d092b3ce8
		linux	/@/boot/vmlinuz-linux root=UUID=e25f324f-adb1-49f2-81b2-324d092b3ce8 rw rootflags=subvol=@  quiet splash loglevel=3 udev.log_level=3 vt.global_cursor_default=0 splash
		initrd	/@/boot/initramfs-linux-fallback.img
	}
	menuentry 'Archcraft Linux, with Kernel: linux (recovery mode)' --class archcraft --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-recovery-e25f324f-adb1-49f2-81b2-324d092b3ce8' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		search --no-floppy --fs-uuid --set=root e25f324f-adb1-49f2-81b2-324d092b3ce8
		linux	/@/boot/vmlinuz-linux root=UUID=e25f324f-adb1-49f2-81b2-324d092b3ce8 rw single rootflags=subvol=@ 
		initrd	/@/boot/initramfs-linux-fallback.img
	}
}

After last hard coding everything is working fine and appears to be in order. I believe that setting the correct mounting parameters in fstab will resolve the issue, after which running sudo grub-mkconfig -o /boot/grub/grub.cfg should finalize the configuration.

However, which parameter should be used correctly? Or is there something else that needs to be considered?

Output of lsblk would be cool.


Also try not to have Windows and Linux on same physical drive. Windows from time to time crosses partition boundaries and messes up with on the bootloader. It’s really cheaper for piece of mind to have two separate physical drives.


My fstab for reference. Boots encrypted btrfs no problem (systemd-boot, anonymized UUIDs):

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=1234-ABCD                            /efi           vfat    fmask=0137,dmask=0027 0 2
/dev/mapper/luks-00000000-0000-0000-0000-000000000000 /              btrfs   subvol=/@,noatime,compress=zstd 0 0
/dev/mapper/luks-00000000-0000-0000-0000-000000000000 /home          btrfs   subvol=/@home,noatime,compress=zstd 0 0
/dev/mapper/luks-00000000-0000-0000-0000-000000000000 /var/cache     btrfs   subvol=/@cache,noatime,compress=zstd 0 0
/dev/mapper/luks-00000000-0000-0000-0000-000000000000 /var/log       btrfs   subvol=/@log,noatime,compress=zstd 0 0
/dev/mapper/luks-00000000-0000-0000-0000-000000000000 /swap          btrfs   subvol=/@swap,noatime 0 0
/swap/swapfile                            swap           swap    defaults   0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0

I don’t think you need for parameters for BTRFS as default are already good (e.g. async SSD TRIM enabled by default).


Instead of grub.cfg, I would modify /etc/default/grub and /etc/grub.d/*


Also using VirtualBox VMs to test out are more convenient than having separate partition. Unless you want to test performance and native stability.

nvme0n1     259:0    0 931,5G  0 disk 
├─nvme0n1p1 259:1    0     2G  0 part /boot/efi
├─nvme0n1p2 259:2    0    16M  0 part 
├─nvme0n1p3 259:3    0  97,6G  0 part 
├─nvme0n1p4 259:4    0  68,4G  0 part /var/log
│                                     /var/cache
│                                     /
├─nvme0n1p5 259:5    0  48,8G  0 part /media/archcraft
├─nvme0n1p6 259:6    0  39,1G  0 part /home
├─nvme0n1p7 259:7    0   3,9G  0 part [SWAP]
└─nvme0n1p8 259:8    0 671,7G  0 part /media/data

The regular version of os-prober doesn’t work on Btrfs installs. You need to install os-prober-btrfs for that. https://aur.archlinux.org/packages/os-prober-btrfs

3 Likes

God bless you! You saved my life. A whole week of trying and that fixed everything.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.