Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ Importing this module will run `btrfs device scan` and pull btrfs modules.
* `autodetect_root_subvol` (true) Autodetect the root subvolume, unless `root_subvol` or `subvol_selector` is set. Depends on `hostonly`.
* `root_subvol` - Set the desired root subvolume.
* `_base_mount_path` (/root_base) Sets where the subvolume selector mounts the base filesytem to scan for subvolumes.
* `btrfs_userspace` (true) Add btrfs binary to be able to mount multi-device btrfs partitions.

#### ugrd.fs.resume

Expand Down
7 changes: 7 additions & 0 deletions src/ugrd/fs/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def _process_subvol_selector(self, subvol_selector: bool) -> None:
self["paths"] = self["_base_mount_path"]


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

@contains("subvol_selector", message="subvol_selector is not enabled, skipping.")
@unset("root_subvol", message="root_subvol is set, skipping.")
@contains("btrfs_userspace", message="btrfs_userspace is not enabled, skipping.")
def select_subvol(self) -> str:
"""Returns a POSIX shell script to list subvolumes on the root volume."""
return f"""
Expand Down Expand Up @@ -134,3 +136,8 @@ def set_root_subvol(self) -> str:
"""Adds the root_subvol to the root_mount options."""
_validate_root_subvol(self)
return f"""setvar root_extra_options ',subvol={self["root_subvol"]}'"""

@contains("btrfs_userspace", message="btrfs_userspace is disabled, skipping adding btrfs to binaries list.", log_level=30)
def pull_btrfs_userspace(self):
self.logger.debug("Adding btrfs to binaries list.")
self["binaries"] = "btrfs"
6 changes: 5 additions & 1 deletion src/ugrd/fs/btrfs.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
binaries = [ "btrfs" ]
kmod_init = [ "btrfs", "crc32c" ] # crc32c is a softdep but more or less required

_base_mount_path = "/root_base"
subvol_selector = false
autodetect_root_subvol = true
btrfs_userspace = true

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

[imports.build_pre]
"ugrd.fs.btrfs" = [ "autodetect_root_subvol" ]

[imports.build_late]
"ugrd.fs.btrfs" = [ "pull_btrfs_userspace" ]

[imports.init_mount]
"ugrd.fs.btrfs" = [ "btrfs_scan", "set_root_subvol", "select_subvol" ]

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