help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple btrfs root subvolumes?


From: Justin Vallon
Subject: Re: Multiple btrfs root subvolumes?
Date: Fri, 9 Apr 2021 22:02:29 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.3.3

On 4/9/21 1:55 PM, Andrei Borzenkov wrote:
On 09.04.2021 08:02, Justin Vallon wrote:
I am wondering whether Grub2 has any btrfs support for multiple root
subvolumes.  It appears it might be able to handle writing a grub.cfg
that would reboot into the current root partition if the partition is
btrfs (though, not sure).


grub does not care about filesystem content at all. It only needs to
know location of kernel (and possibly initrd) and kernel options. How
kernel finds its root is entirely up to this kernel.

I was under the impression that "grub" included os-prober. From the point of view of doing the actual boot-loading and loading the kernel, sure, btrfs is working. I am talking about generating the grub.cfg.

I am on Debian (10).


The grub-mkconfig code seems confused by btrfs:

1) It assumes a device has a single filesystem

btrfs *is* single filesystem.

It is a single filesystem that can be mounted multiple times (at subvolumes). So, mount shows the same device at multiple mount points.


2) It steps through devices, then maps device to mount point

I am not sure what you mean here, but grub needs to resolve file
location on btrfs to the absolute path so it can access it during boot.
No mount points are present during bootloader phase.

Again, talking about os-prober. It sees /dev/vg/btr, and tries to figure out whether the device is a bootable partition. However, it is really device + subvol that is bootable.

3) 30_os-prober has some code for btrfs from os-prober output, but I
don't see where os-prober will generate such entries


os-prober is not part of grub. It was mistake to carry it in grub
sources in the first place.

The code you talk about was added 8 years ago, probably to support some
os-prober patch available in some distribution at this time. Those
distributions that attempt to support boot from subvolumes include
custom, often incompatible, patches to os-prober. There is no real
upstream for os-prober anyway and for all I can tell it is failed
attempt to multiboot linux.

It would be nice if it would be able to generate a grub.cfg that could
boot into any subvolume that was bootable:

Define "bootable subvolume".

I can have btrfs subvol=@debian9 subvol=@debian10 subvol=@debian11, each with its own kernel, etc.

1) Recognize btrfs filesystem
2) Temp mount subvol=. if not already mounted
3) Run os-detector on each subvol


That is more or less what os-prober in openSUSE does.

I came to grub to ask about why os-prober is broken before I realized os-prober is not part of grub.

Does this not work?


I am not sure what you are asking. Does it work now? It depends on what
your distribution provides. Does it work with upstream os-prober? There
is no real upstream for os-prober, the closest is Debian and as you
probably have seen this version does not handle subvolumes. Is it
possible to implement it? Probably, the proof of pudding is in eating.

So, this is really a debian os-prober question. It appears openSUSE is using 1.77, and debian is 1.77, so at least they might be related and I can pull patches from openSUSE. And, maybe push to debian.

I found debian git at https://salsa.debian.org/installer-team/os-prober.git. Now, off to look for opensuse repo.

--
-Justin
JustinVallon@gmail.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]