[mount][bootloader] Ensure root subvolume is set correctly for systemd-boot
This commit is contained in:
parent
ece1e338e0
commit
b0f6530a58
@ -178,10 +178,13 @@ def create_systemd_boot_conf(install_path, efi_dir, uuid, entry, entry_name, ker
|
|||||||
+ partition["luksMapperName"]]
|
+ partition["luksMapperName"]]
|
||||||
|
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
# systemd-boot with a BTRFS root filesystem needs to be told
|
# systemd-boot with a BTRFS root filesystem needs to be told abouut the root subvolume.
|
||||||
# about the root subvolume.
|
# If a btrfs root subvolume wasn't set, it means the root is directly on the partition
|
||||||
|
# and this option isn't needed
|
||||||
if is_btrfs_root(partition):
|
if is_btrfs_root(partition):
|
||||||
kernel_params.append("rootflags=subvol=@")
|
btrfs_root_subvolume = libcalamares.globalstorage.value("btrfsRootSubvolume")
|
||||||
|
if btrfs_root_subvolume:
|
||||||
|
kernel_params.append("rootflags=subvol=" + btrfs_root_subvolume)
|
||||||
|
|
||||||
# zfs needs to be told the location of the root dataset
|
# zfs needs to be told the location of the root dataset
|
||||||
if is_zfs_root(partition):
|
if is_zfs_root(partition):
|
||||||
|
@ -20,6 +20,7 @@ import os
|
|||||||
import libcalamares
|
import libcalamares
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
|
|
||||||
_ = gettext.translation("calamares-python",
|
_ = gettext.translation("calamares-python",
|
||||||
localedir=libcalamares.utils.gettext_path(),
|
localedir=libcalamares.utils.gettext_path(),
|
||||||
languages=libcalamares.utils.gettext_languages(),
|
languages=libcalamares.utils.gettext_languages(),
|
||||||
@ -58,15 +59,16 @@ def get_btrfs_subvolumes(partitions):
|
|||||||
if btrfs_subvolumes is None:
|
if btrfs_subvolumes is None:
|
||||||
libcalamares.utils.warning("No configuration for btrfsSubvolumes")
|
libcalamares.utils.warning("No configuration for btrfsSubvolumes")
|
||||||
if not btrfs_subvolumes:
|
if not btrfs_subvolumes:
|
||||||
btrfs_subvolumes = [ dict(mountPoint="/", subvolume="/@"), dict(mountPoint="/home", subvolume="/@home") ]
|
btrfs_subvolumes = [dict(mountPoint="/", subvolume="/@"), dict(mountPoint="/home", subvolume="/@home")]
|
||||||
|
|
||||||
# Filter out the subvolumes which have a dedicated partition
|
# Filter out the subvolumes which have a dedicated partition
|
||||||
non_root_partition_mounts = [ m for m in [ p.get("mountPoint", None) for p in partitions ] if m is not None and m != '/' ]
|
non_root_partition_mounts = [m for m in [p.get("mountPoint", None) for p in partitions] if
|
||||||
btrfs_subvolumes = list(filter(lambda s : s["mountPoint"] not in non_root_partition_mounts, btrfs_subvolumes))
|
m is not None and m != '/']
|
||||||
|
btrfs_subvolumes = list(filter(lambda s: s["mountPoint"] not in non_root_partition_mounts, btrfs_subvolumes))
|
||||||
|
|
||||||
# If we have a swap **file**, give it a separate subvolume.
|
# If we have a swap **file**, give it a separate subvolume.
|
||||||
swap_choice = libcalamares.globalstorage.value( "partitionChoices" )
|
swap_choice = libcalamares.globalstorage.value("partitionChoices")
|
||||||
if swap_choice and swap_choice.get( "swap", None ) == "file":
|
if swap_choice and swap_choice.get("swap", None) == "file":
|
||||||
btrfs_subvolumes.append({'mountPoint': '/swap', 'subvolume': '/@swap'})
|
btrfs_subvolumes.append({'mountPoint': '/swap', 'subvolume': '/@swap'})
|
||||||
|
|
||||||
return btrfs_subvolumes
|
return btrfs_subvolumes
|
||||||
@ -189,9 +191,11 @@ def mount_partition(root_mount_point, partition, partitions):
|
|||||||
libcalamares.globalstorage.insert("btrfsSubvolumes", btrfs_subvolumes)
|
libcalamares.globalstorage.insert("btrfsSubvolumes", btrfs_subvolumes)
|
||||||
# Create the subvolumes that are in the completed list
|
# Create the subvolumes that are in the completed list
|
||||||
for s in btrfs_subvolumes:
|
for s in btrfs_subvolumes:
|
||||||
subprocess.check_call(['btrfs', 'subvolume', 'create',
|
subprocess.check_call(["btrfs", "subvolume", "create",
|
||||||
root_mount_point + s['subvolume']])
|
root_mount_point + s["subvolume"]])
|
||||||
|
if s["mountPoint"] == "/":
|
||||||
|
# insert the root subvolume into global storage
|
||||||
|
libcalamares.globalstorage.insert("btrfsRootSubvolume", s["subvolume"])
|
||||||
subprocess.check_call(["umount", "-v", root_mount_point])
|
subprocess.check_call(["umount", "-v", root_mount_point])
|
||||||
|
|
||||||
device = partition["device"]
|
device = partition["device"]
|
||||||
@ -204,9 +208,9 @@ def mount_partition(root_mount_point, partition, partitions):
|
|||||||
mount_option = "subvol={}".format(s['subvolume'])
|
mount_option = "subvol={}".format(s['subvolume'])
|
||||||
subvolume_mountpoint = mount_point[:-1] + s['mountPoint']
|
subvolume_mountpoint = mount_point[:-1] + s['mountPoint']
|
||||||
if libcalamares.utils.mount(device,
|
if libcalamares.utils.mount(device,
|
||||||
subvolume_mountpoint,
|
subvolume_mountpoint,
|
||||||
fstype,
|
fstype,
|
||||||
",".join([mount_option, partition.get("options", "")])) != 0:
|
",".join([mount_option, partition.get("options", "")])) != 0:
|
||||||
libcalamares.utils.warning("Cannot mount {}".format(device))
|
libcalamares.utils.warning("Cannot mount {}".format(device))
|
||||||
|
|
||||||
|
|
||||||
@ -220,7 +224,7 @@ def run():
|
|||||||
if not partitions:
|
if not partitions:
|
||||||
libcalamares.utils.warning("partitions is empty, {!s}".format(partitions))
|
libcalamares.utils.warning("partitions is empty, {!s}".format(partitions))
|
||||||
return (_("Configuration Error"),
|
return (_("Configuration Error"),
|
||||||
_("No partitions are defined for <pre>{!s}</pre> to use." ).format("mount"))
|
_("No partitions are defined for <pre>{!s}</pre> to use.").format("mount"))
|
||||||
|
|
||||||
root_mount_point = tempfile.mkdtemp(prefix="calamares-root-")
|
root_mount_point = tempfile.mkdtemp(prefix="calamares-root-")
|
||||||
|
|
||||||
@ -237,7 +241,7 @@ def run():
|
|||||||
# This way, we ensure / is mounted before the rest, and every mount point
|
# This way, we ensure / is mounted before the rest, and every mount point
|
||||||
# is created on the right partition (e.g. if a partition is to be mounted
|
# is created on the right partition (e.g. if a partition is to be mounted
|
||||||
# under /tmp, we make sure /tmp is mounted before the partition)
|
# under /tmp, we make sure /tmp is mounted before the partition)
|
||||||
mountable_partitions = [ p for p in partitions + extra_mounts if "mountPoint" in p and p["mountPoint"] ]
|
mountable_partitions = [p for p in partitions + extra_mounts if "mountPoint" in p and p["mountPoint"]]
|
||||||
mountable_partitions.sort(key=lambda x: x["mountPoint"])
|
mountable_partitions.sort(key=lambda x: x["mountPoint"])
|
||||||
try:
|
try:
|
||||||
for partition in mountable_partitions:
|
for partition in mountable_partitions:
|
||||||
|
Loading…
Reference in New Issue
Block a user