From ffd9d75cde509e617f5867c64c74f9ac23279603 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 15 Aug 2023 10:31:47 +0200 Subject: [PATCH 1/4] repart: Allow using Subvolumes= with automatic --offline If we fail to allocate a loopback device and subvolumes are configured, we fail instead of falling back to a regular file. --- src/partition/repart.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index 7621d32a53..09b84e5080 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -1756,9 +1756,9 @@ static int partition_read_definition(Partition *p, const char *path, const char "SizeMinBytes=/SizeMaxBytes= cannot be used with Verity=%s", verity_mode_to_string(p->verity)); - if (!strv_isempty(p->subvolumes) && arg_offline != 0) + if (!strv_isempty(p->subvolumes) && arg_offline > 0) return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EOPNOTSUPP), - "Subvolumes= can only be used with --offline=no"); + "Subvolumes= cannot be used with --offline=yes"); /* Verity partitions are read only, let's imply the RO flag hence, unless explicitly configured otherwise. */ if ((IN_SET(p->type.designator, @@ -3494,7 +3494,7 @@ static int partition_target_prepare( if (arg_offline <= 0) { r = loop_device_make(whole_fd, O_RDWR, p->offset, size, context->sector_size, 0, LOCK_EX, &d); - if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)))) + if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)) || !strv_isempty(p->subvolumes))) return log_error_errno(r, "Failed to make loopback device of future partition %" PRIu64 ": %m", p->partno); if (r >= 0) { t->loop = TAKE_PTR(d); @@ -6022,7 +6022,7 @@ static int context_minimize(Context *context) { if (arg_offline <= 0) { r = loop_device_make(fd, O_RDWR, 0, UINT64_MAX, context->sector_size, 0, LOCK_EX, &d); - if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)))) + if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)) || !strv_isempty(p->subvolumes))) return log_error_errno(r, "Failed to make loopback device of %s: %m", temp); } @@ -6125,7 +6125,7 @@ static int context_minimize(Context *context) { if (arg_offline <= 0) { r = loop_device_make(fd, O_RDWR, 0, UINT64_MAX, context->sector_size, 0, LOCK_EX, &d); - if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)))) + if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)) || !strv_isempty(p->subvolumes))) return log_error_errno(r, "Failed to make loopback device of %s: %m", temp); } From ade85cd51924790c78e52adf6c7cddb1a30e2726 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 15 Aug 2023 10:32:45 +0200 Subject: [PATCH 2/4] repart: Rework read-only logic verity sig partitions can't actually be marked read-only, so let's not do that to avoid an ugly warning about that. Instead, let's just make sure that we mark verity hash and verity data partitions as read-only. --- src/partition/repart.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index 09b84e5080..4410cad1e5 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -1763,9 +1763,7 @@ static int partition_read_definition(Partition *p, const char *path, const char /* Verity partitions are read only, let's imply the RO flag hence, unless explicitly configured otherwise. */ if ((IN_SET(p->type.designator, PARTITION_ROOT_VERITY, - PARTITION_ROOT_VERITY_SIG, - PARTITION_USR_VERITY, - PARTITION_USR_VERITY_SIG) || p->verity != VERITY_OFF) && p->read_only < 0) + PARTITION_USR_VERITY) || p->verity == VERITY_DATA) && p->read_only < 0) p->read_only = true; /* Default to "growfs" on, unless read-only */ From 06ba811a760da20da4226256015ff32bb7b987d2 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 15 Aug 2023 10:33:34 +0200 Subject: [PATCH 3/4] mkosi: Create a few subvolumes in the root partition Let's exercise the repart Subvolumes= setting by creating a few subvolumes in the root partition when we create it. --- mkosi.presets/system/mkosi.extra/usr/lib/repart.d/20-root.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkosi.presets/system/mkosi.extra/usr/lib/repart.d/20-root.conf b/mkosi.presets/system/mkosi.extra/usr/lib/repart.d/20-root.conf index 2f92af248f..71eb9e38c4 100644 --- a/mkosi.presets/system/mkosi.extra/usr/lib/repart.d/20-root.conf +++ b/mkosi.presets/system/mkosi.extra/usr/lib/repart.d/20-root.conf @@ -4,3 +4,5 @@ Type=root Format=btrfs SizeMinBytes=1G +Subvolumes=/home /var +MakeDirectories=/home /var From c3e83f09ea4a1a12e2c5043d8635656075fe17d4 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 15 Aug 2023 10:35:56 +0200 Subject: [PATCH 4/4] mkosi: Update to v15.1 release --- .github/workflows/mkosi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index 5a34e997db..d5f587f4ad 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -76,7 +76,7 @@ jobs: steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - - uses: systemd/mkosi@9ffcdac128c66935aa5d5a98633fa7498bce92d1 + - uses: systemd/mkosi@0af3f8a35c3be0e54b20234be7ab478d25bcc740 - name: Configure run: |