09.01.2026 18:16, Marko Zubin wrote:
I'm trying to write a grub.cfg file that will add a menu entry that
boots a Linux kernel from the default subvolume of a btrfs partition.
My problem is that I don't seem to be able to find a way to access the
default subvolume of said partition.
In my case the partition is (hd0,gpt2).
The default subvolume is set to "@/.snapshots/1/snapshot".
The kernel is located at /boot/vmlinuz-linux of the beforementioned
subvolume.
(hd0,gpt2)/ points to subvolume 5 of the btrfs partition and not to the
default subvolume.
Once upon a time grub used the default subvolume as the starting point.
But it made it impossible to access anything outside of the default
subvolume which prompted to reverse this logic.
Therefore the location of the kernel would be:
(hd0,gpt2)/@/.snapshots/1/snapshot/boot/vmlinuz-linux
My questions would be as follows:
1. Does GRUB provide a way to access the default subvolume of a btrfs
partition instead of subvolume 5?
Your question is ambiguous. Sure, grub has no problem accessing any
subvolume including the default subvolume. But the upstream grub does
not provide any command to find out which subvolume is the default.
2. Is there a way for GRUB to store the path of the default subvolume of
a btrs partition to a variable (so I can then manually prepend it to the
kernel path like in the above example)?
Again, it is rather vague. grub itself (meaning - the binary that runs
on boot) does not store anything anywhere. Nothing stops you from
storing the reference to the default subvolume in the grub.cfg or
grubenv when preparing the grub configuration. But again, upstream grub
has no provision for it. Upstream grub grub-mkconfig always generates
the absolute path names starting from the top so it does not need to
know what subvolume is the default.
I tried searching online but someone created a project named
"grub-btrfs" and it makes searching for actual information on grub's
btrfs support quite inconvenient.
Thanks