From 951ddfb72a89b4fe656a8000250202483d24d92d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Dec 2021 23:06:02 +0100 Subject: [PATCH 1/3] [mount] Experimental: accept 'no' for subvolumes If there is no subvolume set, skip creation of that subvolume. This allows root to be on a bare FS, without a tag or subvolume name. To achieve this, use subvolume: no (no quotes there) in the YAML. --- src/modules/mount/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/mount/main.py b/src/modules/mount/main.py index 900342e6d..f186b0d26 100644 --- a/src/modules/mount/main.py +++ b/src/modules/mount/main.py @@ -191,6 +191,8 @@ def mount_partition(root_mount_point, partition, partitions): libcalamares.globalstorage.insert("btrfsSubvolumes", btrfs_subvolumes) # Create the subvolumes that are in the completed list for s in btrfs_subvolumes: + if not s["subvolume"]: + continue subprocess.check_call(["btrfs", "subvolume", "create", root_mount_point + s["subvolume"]]) if s["mountPoint"] == "/": From 96ccf256b207fa3f41dae816d31b4686b492ec1c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Dec 2021 22:02:14 +0100 Subject: [PATCH 2/3] [mount] Add documentation to the config file --- src/modules/mount/mount.conf | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/modules/mount/mount.conf b/src/modules/mount/mount.conf index 6168e97cc..84dca05a7 100644 --- a/src/modules/mount/mount.conf +++ b/src/modules/mount/mount.conf @@ -42,15 +42,24 @@ extraMountsEfi: mountPoint: /sys/firmware/efi/efivars # Btrfs subvolumes to create if root filesystem is on btrfs volume. -# If mountpoint is mounted already to another partition, it is ignored. +# If *mountpoint* is mounted already to another partition, it is ignored. # Separate subvolume for swapfile is handled separately and automatically. +# +# It is possible to prevent subvolume creation -- this is likely only relevant +# for the root (/) subvolume -- by giving an empty string as a subvolume +# name. In this case no subvolume will be created. When using snapper as +# a rollback mechanism, it is recommended to **not** create a subvolume +# for root. btrfsSubvolumes: - mountPoint: / subvolume: /@ + # As an alternative: + # + # subvolume: "" - mountPoint: /home subvolume: /@home - mountPoint: /var/cache subvolume: /@cache - mountPoint: /var/log - subvolume: /@log \ No newline at end of file + subvolume: /@log From f26c81700d7c34b5411038acd245ef797f95fdd6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Dec 2021 22:08:17 +0100 Subject: [PATCH 3/3] [fstab] Suppress empty subvol= options in fstab --- src/modules/fstab/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index 261d3cadb..426761453 100644 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -258,7 +258,8 @@ class FstabGenerator(object): if mount_point == "/": self.root_is_ssd = is_ssd - if filesystem == "btrfs" and "subvol" in partition: + # If there's a set-and-not-empty subvolume set, add it + if filesystem == "btrfs" and partition.get("subvol",None): options = "subvol={},".format(partition["subvol"]) + options if has_luks: