mount: Make sure extra mounts are mounted right after /

When the rootfs partition is read-only, mount points for the other
partitions cannot be created, therefore they need to be created in a
tmpfs, already mounted somewhere in `/`.

However, the extra mounts are only mounted at the end, which causes an
error as no tmpfs is currently mounted.

This patch makes sure all extra mounts are mounted right after the `/`
partition, allowing the use of a read-only rootfs.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
This commit is contained in:
Arnaud Ferraris 2019-07-17 12:15:22 +02:00
parent 8c78a6cdfa
commit bf47e761b0

View File

@ -37,17 +37,7 @@ _ = gettext.translation("calamares-python",
def pretty_name(): def pretty_name():
return _("Mounting partitions.") return _("Mounting partitions.")
def mount_part(root_mount_point, partition, partitions):
def mount_partitions(root_mount_point, partitions):
"""
Pass back mount point and filesystem for each partition.
:param root_mount_point:
:param partitions:
"""
for partition in partitions:
if "mountPoint" not in partition or not partition["mountPoint"]:
continue
# Create mount point with `+` rather than `os.path.join()` because # Create mount point with `+` rather than `os.path.join()` because
# `partition["mountPoint"]` starts with a '/'. # `partition["mountPoint"]` starts with a '/'.
raw_mount_point = partition["mountPoint"] raw_mount_point = partition["mountPoint"]
@ -136,6 +126,21 @@ def mount_partitions(root_mount_point, partitions):
["subvol=@home", partition.get("options", "")]), ["subvol=@home", partition.get("options", "")]),
) )
def mount_partitions(root_mount_point, partitions, extra_mounts=None):
"""
Pass back mount point and filesystem for each partition.
:param root_mount_point:
:param partitions:
:param extra_mounts:
"""
for partition in partitions:
if "mountPoint" not in partition or not partition["mountPoint"]:
continue
mount_part(root_mount_point, partition, partitions)
if partition["mountPoint"] is "/" and extra_mounts is not None:
mount_partitions(root_mount_point, extra_mounts)
def run(): def run():
""" """
@ -160,8 +165,7 @@ def run():
# Sort by mount points to ensure / is mounted before the rest # Sort by mount points to ensure / is mounted before the rest
partitions.sort(key=lambda x: x["mountPoint"]) partitions.sort(key=lambda x: x["mountPoint"])
mount_partitions(root_mount_point, partitions) mount_partitions(root_mount_point, partitions, extra_mounts)
mount_partitions(root_mount_point, extra_mounts)
all_extra_mounts = extra_mounts all_extra_mounts = extra_mounts
if libcalamares.globalstorage.value("firmwareType") == "efi": if libcalamares.globalstorage.value("firmwareType") == "efi":