Skip to content

Commit

Permalink
filesystem: pass _netdev option for mounts on remote storage
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
  • Loading branch information
ogayot committed Jan 19, 2024
1 parent 7f216a9 commit b8c2431
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion subiquity/common/filesystem/manipulator.py
Expand Up @@ -42,7 +42,9 @@ class FilesystemManipulator:
def create_mount(self, fs, spec):
if spec.get("mount") is None:
return
mount = self.model.add_mount(fs, spec["mount"])
mount = self.model.add_mount(
fs, spec["mount"], on_remote_storage=spec.get("on-remote-storage", False)
)
if self.model.needs_bootloader_partition():
vol = fs.volume
if vol.type == "partition" and boot.can_be_boot_device(vol.device):
Expand Down Expand Up @@ -240,6 +242,9 @@ def can_resize_partition(self, partition):
def partition_disk_handler(self, disk, spec, *, partition=None, gap=None):
log.debug("partition_disk_handler: %s %s %s %s", disk, spec, partition, gap)

if disk.on_remote_storage():
spec["on-remote-storage"] = True

if partition is not None:
if "size" in spec and spec["size"] != partition.size:
trailing, gap_size = gaps.movable_trailing_partitions_and_gap_size(
Expand Down Expand Up @@ -294,6 +299,9 @@ def logical_volume_handler(self, vg, spec, *, partition, gap):

log.debug("logical_volume_handler: %s %s %s", vg, lv, spec)

if vg.on_remote_storage():
spec["on-remote-storage"] = True

if lv is not None:
if "name" in spec:
lv.name = spec["name"]
Expand Down
7 changes: 5 additions & 2 deletions subiquity/models/filesystem.py
Expand Up @@ -2166,10 +2166,13 @@ def remove_filesystem(self, fs):
raise Exception("can only remove unmounted filesystem")
self._remove(fs)

def add_mount(self, fs, path):
def add_mount(self, fs, path, *, on_remote_storage=False):
if fs._mount is not None:
raise Exception(f"{fs} is already mounted")
m = Mount(m=self, device=fs, path=path)
options = None
if on_remote_storage:
options = "defaults,_netdev"
m = Mount(m=self, device=fs, path=path, options=options)
self._actions.append(m)
return m

Expand Down

0 comments on commit b8c2431

Please sign in to comment.