Skip to content

Commit 6e3c331

Browse files
committed
add auto_late_mounts, improve documentation
Signed-off-by: Zen <[email protected]>
1 parent 859f821 commit 6e3c331

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

docs/configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,16 @@ Additional modules include:
245245
246246
`mounts`: A dictionary containing entries for mounts, with their associated config.
247247

248+
Mounts defined here are mounted before `init_main` is run. This cannot be used for mounts backed by LUKS, LVM, or MDRAID devices, because the backend will not be available when these mounts are attempted.
249+
250+
> `mounts` can be automatically populated by configuring paths as list items in `auto_mounts`.
251+
248252
`mounts.root` is predefined to have a destination of `/target_rootfs` and defines the root filesystem mount, used by `switch_root`.
249253

254+
`late_mounts`: A dictionary containing entries for mounts that should be mounted after `init_main` is run.
255+
256+
> `late_mounts` can be automatically populated by configuring paths as list items in `auto_late_mounts`.
257+
250258
Each mount has the following available parameters:
251259

252260
* `type` (auto) Mount filesystem type.
@@ -285,6 +293,8 @@ label = "extra"
285293

286294
Paths added to `auto_mounts` will be auto-configured to mount before `init_main` is run.
287295

296+
Paths added to `auto_late_mounts` will be auto-configured to mount after `init_main` is run.
297+
288298
#### ugrd.fs.fakeudev
289299

290300
This module is used to create fake udev entries for DM devices.

src/ugrd/fs/mounts.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,14 @@ def autodetect_mounts(self) -> None:
866866
_autodetect_mount(self, mountpoint)
867867

868868

869+
@contains("auto_late_mounts", "Skipping auto late mounts, auto_late_mounts is empty.", log_level=10)
870+
@contains("hostonly", "Skipping late mount autodetection, hostonly mode is disabled.", log_level=30)
871+
def autodetect_late_mounts(self) -> None:
872+
"""Configured the late_mounts config for a device based on the host mount config."""
873+
for mountpoint in self["auto_late_mounts"]:
874+
_autodetect_mount(self, mountpoint, mount_class="late_mounts")
875+
876+
869877
def mount_base(self) -> list[str]:
870878
"""Generates mount commands for the base mounts.
871879
Must be run before variables are used, as it creates the /run/ugrd directory.

src/ugrd/fs/mounts.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ autodetect_init_mount = true
2222

2323
[imports.build_enum]
2424
"ugrd.fs.mounts" = [ "get_mounts_info", "get_virtual_block_info", "get_blkid_info", "get_zpool_info",
25-
"autodetect_root", "autodetect_mounts", "autodetect_init_mount" ]
25+
"autodetect_root", "autodetect_mounts", "autodetect_late_mounts", "autodetect_init_mount" ]
2626

2727
[imports.build_tasks]
2828
"ugrd.fs.mounts" = [ "export_mount_info" ]
@@ -58,6 +58,7 @@ mount_devpts = "bool" # Whether or not to mount devpts
5858
run_dirs = "NoDupFlatList" # A list of directories to be created under /run
5959
late_mounts = "dict" # Like mounts, but run after the root is mounted
6060
auto_mounts = "NoDupFlatList" # A list of mounts to be automatically added to the mounts list
61+
auto_late_mounts = "NoDupFlatList" # A list of mounts to be automatically added to the late mounts list
6162
mount_timeout = "float" # The time to wait between mount attempts
6263
mount_retries = "int" # The number of times to re-attempt mounting the fstab, infinite if not set
6364
mount_cmd = "str" # The mount command called by mount_root, can be overridden

0 commit comments

Comments
 (0)