Skip to content

Commit 5ff4d6e

Browse files
authored
Merge pull request #371 from redjard/no-userspace-btrfs2
add flag btrfs_userspace
2 parents d1ab3bb + f680a73 commit 5ff4d6e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

docs/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ Importing this module will run `btrfs device scan` and pull btrfs modules.
324324
* `autodetect_root_subvol` (true) Autodetect the root subvolume, unless `root_subvol` or `subvol_selector` is set. Depends on `hostonly`.
325325
* `root_subvol` - Set the desired root subvolume.
326326
* `_base_mount_path` (/root_base) Sets where the subvolume selector mounts the base filesytem to scan for subvolumes.
327+
* `btrfs_userspace` (true) Add btrfs binary to be able to mount multi-device btrfs partitions.
327328

328329
#### ugrd.fs.resume
329330

src/ugrd/fs/btrfs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def _process_subvol_selector(self, subvol_selector: bool) -> None:
7575
self["paths"] = self["_base_mount_path"]
7676

7777

78+
@contains("btrfs_userspace", message="btrfs_userspace is disabled, will not add btrfs_scan to init.")
7879
def btrfs_scan(self) -> str:
7980
"""scan for new btrfs devices."""
8081
return 'einfo "$(btrfs device scan)"'
@@ -98,6 +99,7 @@ def autodetect_root_subvol(self):
9899

99100
@contains("subvol_selector", message="subvol_selector is not enabled, skipping.")
100101
@unset("root_subvol", message="root_subvol is set, skipping.")
102+
@contains("btrfs_userspace", message="btrfs_userspace is not enabled, skipping.")
101103
def select_subvol(self) -> str:
102104
"""Returns a POSIX shell script to list subvolumes on the root volume."""
103105
return f"""
@@ -134,3 +136,8 @@ def set_root_subvol(self) -> str:
134136
"""Adds the root_subvol to the root_mount options."""
135137
_validate_root_subvol(self)
136138
return f"""setvar root_extra_options ',subvol={self["root_subvol"]}'"""
139+
140+
@contains("btrfs_userspace", message="btrfs_userspace is disabled, skipping adding btrfs to binaries list.", log_level=30)
141+
def pull_btrfs_userspace(self):
142+
self.logger.debug("Adding btrfs to binaries list.")
143+
self["binaries"] = "btrfs"

src/ugrd/fs/btrfs.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
binaries = [ "btrfs" ]
21
kmod_init = [ "btrfs", "crc32c" ] # crc32c is a softdep but more or less required
32

43
_base_mount_path = "/root_base"
54
subvol_selector = false
65
autodetect_root_subvol = true
6+
btrfs_userspace = true
77

88
[imports.config_processing]
99
"ugrd.fs.btrfs" = [ "_process_root_subvol", "_process_subvol_selector" ]
1010

1111
[imports.build_pre]
1212
"ugrd.fs.btrfs" = [ "autodetect_root_subvol" ]
1313

14+
[imports.build_late]
15+
"ugrd.fs.btrfs" = [ "pull_btrfs_userspace" ]
16+
1417
[imports.init_mount]
1518
"ugrd.fs.btrfs" = [ "btrfs_scan", "set_root_subvol", "select_subvol" ]
1619

@@ -28,3 +31,4 @@ _base_mount_path = "Path" # Set the mount point for the root filesystem when us
2831
root_subvol = "str" # Set the default btrfs subvolume for the root filesystem
2932
subvol_selector = "bool" # Select a btrfs subvolume for the root partition at runtime
3033
autodetect_root_subvol = "bool" # Automatically detect the root subvolume
34+
btrfs_userspace = "bool" # Add btrfs binary to be able to mount multi-device btrfs partitions

0 commit comments

Comments
 (0)