Hi Nicholas, On Sat, 2026-08-08 at 21:54 -0400, Nicholas D Steeves wrote: > Kevin Locke <[email protected]> writes: >> I believe this bug only appears in the MODULES=dep case and that >> MODULES=most works as intended. >> >> What do you think about option 1 (use a heuristic to detect whether >> btrfs is in use - possibly already implemented by initramfs-tools to >> determine whether to include btrfs.ko) > > If that's the case, this bug should be reassigned to initramfs-tools. > In addition to currently mounted fs, the heuristic should also include > unmounted btrfs fs in /etc/fstab. If initramfs-tools has a plugin > system that I'm unaware of then I'd appreciate it if someone could save > me some time and spoons by pointing me in the right direction.
Unfortunately, I'm not aware of a plugin system beyond the shell functions exposed to hooks. I had hoped initramfs-tools might expose a suitable hook function we could use, but the best option I can find to reuse the detection logic is to check for the presence of btrfs.ko in the initramfs as it is being built, since modules are copied before hooks are run[1], then include the btrfs scripts/tools only when btrfs.ko is present (or built into the kernel). [1]: https://salsa.debian.org/kernel-team/initramfs-tools/-/blob/v0.151/mkinitramfs?ref_type=tags#L416 Unfortunately, I don't believe the heuristic used by initramfs-tools matches your requirements. Based on a quick investigation: [dep_add_modules] calls [dep_add_modules_mount] for / and /usr, which calls [manual_add_modules] for the detected fstype of the given mountpoint. In effect, btrfs is included only if / or /usr are active btrfs mounts. [dep_add_modules]: https://salsa.debian.org/kernel-team/initramfs-tools/-/blob/v0.151/hook-functions?ref_type=tags#L598 [dep_add_modules_mount]: https://salsa.debian.org/kernel-team/initramfs-tools/-/blob/v0.151/hook-functions?ref_type=tags#L489 [manual_add_modules]: https://salsa.debian.org/kernel-team/initramfs-tools/-/blob/v0.151/hook-functions?ref_type=tags#L97 What are the use cases you have in mind where btrfs would be required in the initramfs for inactive mounts, and mounts other than / and /usr? >> vs option 3 (unconditionally >> add the btrfs module) for the MODULES=dep case? I'd lean toward >> option 1, but I wouldn't be opposed to option 3 if it's more robust or >> maintainable, especially given the lvm2 precedent you noted. > > We can do this in btrfs-progs, like lvm2. This seems like a simple, workable solution to me. Although not ideal for initramfs size, it seems like a pragmatic choice to me. Cheers, Kevin
signature.asc
Description: PGP signature

