Skip to content

Commit 846d67b

Browse files
committed
don't umount livecd mounts
Signed-off-by: Zen <[email protected]>
1 parent 674e064 commit 846d67b

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

src/ugrd/fs/livecd.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
__author__ = "desultory"
2-
__version__ = "0.5.0"
2+
__version__ = "0.5.1"
33

44
from zenlib.util import contains
55

66

77
@contains("livecd_label", "livecd_label must be set to the label of the livecd.", raise_exception=True)
88
def generate_livecd_mount(self):
99
"""Makes the mounts entry for livecd base."""
10-
self["mounts"] = {"livecd": {"label": self.livecd_label, "no_validate": True}}
11-
12-
13-
def prepare_squashfs_mount(self) -> str:
14-
"""Create the folder for the squashfs mount in /run"""
15-
return "edebug $(mkdir -pv /run/squashfs)"
10+
self["mounts"] = {"livecd": {"label": self.livecd_label, "no_validate": True, "no_umount": True}}
1611

1712

1813
@contains("squashfs_image", "squashfs_image must be set to the path of the squashfs image to mount.", raise_exception=True)
@@ -23,7 +18,6 @@ def set_squashfs_mount(self):
2318
"type": "squashfs",
2419
"options": ["loop"],
2520
"path": f"/livecd/{self.squashfs_image}",
26-
"destination": "/run/squashfs",
2721
"no_validate": True,
2822
}
2923
}

src/ugrd/fs/livecd.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
modules = ["ugrd.fs.overlayfs"]
22

33
squashfs_image = 'image.squashfs'
4-
lowerdir = "/run/squashfs"
54
hostonly = false
65

76
kmod_init = ['hfsplus', 'nls_utf8', 'squashfs', 'isofs', 'loop']
87

98
[imports.build_pre]
109
"ugrd.fs.livecd" = ["generate_livecd_mount", "set_squashfs_mount"]
1110

12-
[imports.init_early]
13-
"ugrd.fs.livecd" = ["prepare_squashfs_mount"]
14-
1511
[custom_parameters]
1612
squashfs_image = "Path" # the path to the squashfs image (at runtime)
1713
livecd_label = "str" # The label of the livecd

src/ugrd/fs/mounts.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "desultory"
2-
__version__ = "5.4.2"
2+
__version__ = "5.5.0"
33

44
from pathlib import Path
55

@@ -14,6 +14,7 @@
1414
"options",
1515
"no_validate",
1616
"no_validate_options",
17+
"no_umount",
1718
"base_mount",
1819
*SOURCE_TYPES,
1920
]
@@ -211,10 +212,11 @@ def generate_fstab(self, mount_class="mounts", filename="/etc/fstab") -> None:
211212

212213

213214
def umount_fstab(self) -> list[str]:
214-
"""Generates a function to unmount all mounts in the fstab."""
215+
"""Generates a function to unmount all mounts which are not base_mounts
216+
and do not have no_umount set"""
215217
mountpoints = []
216218
for mount_info in self["mounts"].values():
217-
if mount_info.get("base_mount"):
219+
if mount_info.get("base_mount") or mount_info.get("no_umount"):
218220
continue
219221
if str(mount_info.get("destination")) == str(self["mounts"]["root"]["destination"]):
220222
continue
@@ -223,7 +225,7 @@ def umount_fstab(self) -> list[str]:
223225
if not mountpoints:
224226
return []
225227

226-
out = [f"einfo 'Unmounting filesystems: {' ,'.join(mountpoints)}'"]
228+
out = [f"einfo 'Unmounting filesystems: {', '.join(mountpoints)}'"]
227229
for mountpoint in mountpoints:
228230
out.append(f"umount {mountpoint} || ewarn 'Failed to unmount: {mountpoint}'")
229231

src/ugrd/fs/overlayfs.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1+
__version__ = "0.1.0"
2+
13
from zenlib.util import unset
24

3-
@unset('lowerdir', "lowerdir is already set, skipping detection.")
5+
6+
@unset("lowerdir", "lowerdir is already set, skipping detection.")
47
def detect_lowerdir(self):
58
"""Detect the lowerdir using the mounts['root']['destination']"""
6-
self['lowerdir'] = self.mounts['root']['destination']
7-
self.logger.info("Detected lowerdir: %s" % self['lowerdir'])
9+
self["lowerdir"] = self.mounts["root"]["destination"]
10+
self.logger.info("Detected lowerdir: %s" % self["lowerdir"])
811

912

10-
def init_overlayfs(self) -> list[str]:
13+
def init_overlayfs(self) -> str:
1114
"""Returns bash lines to create the upperdir and workdir
1215
Uses /run/upperdir and /run/workdir."""
13-
return ["edebug $(mkdir -pv /run/upperdir /run/workdir)"]
14-
15-
def mount_overlayfs(self) -> list[str]:
16-
"""Returns bash lines to mount the overlayfs based on the lowerdir"""
17-
return [
18-
"einfo $(mount -t overlay overlay -o lowerdir=%s,upperdir=/run/upperdir,workdir=/run/workdir $(readvar SWITCH_ROOT_TARGET))" % self['lowerdir']
19-
]
20-
16+
return "edebug $(mkdir -pv /run/upperdir /run/workdir)"
2117

2218

19+
def mount_overlayfs(self) -> str:
20+
"""Returns bash lines to mount the overlayfs based on the defined lowerdir"""
21+
return 'edebug "[%s] Mounting overlayfs at $(readvar SWITCH_ROOT_TARGET)): $(mount -t overlay overlay -o lowerdir=%s,upperdir=/run/upperdir,workdir=/run/workdir $(readvar SWITCH_ROOT_TARGET))"' % (self["lowerdir"], self["lowerdir"])

0 commit comments

Comments
 (0)