filesystem: pass _netdev option for mounts on remote storage

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2024-01-10 15:36:32 +01:00
parent c3de13d10c
commit 376131b04d
2 changed files with 14 additions and 3 deletions

View File

@ -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):
@ -240,6 +242,9 @@ class FilesystemManipulator:
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(
@ -294,6 +299,9 @@ class FilesystemManipulator:
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"]

View File

@ -2166,10 +2166,13 @@ class FilesystemModel:
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