From 381304a209154c1a506362d4f48c9c349736f7fa Mon Sep 17 00:00:00 2001 From: Michael Ferrari Date: Fri, 27 Jun 2025 18:26:10 +0200 Subject: [PATCH] repart: add support for `Format=empty` This is a new meta value for the `Format=` option, which is equivalent as specifying `Label=_empty` and `NoAuto=1` for compatibility with sd-sysupdate. Closes: https://github.com/systemd/systemd/issues/34596 --- man/repart.d.xml | 3 +++ src/repart/repart.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/man/repart.d.xml b/man/repart.d.xml index d3a8f6fcea7..eac8ae7174e 100644 --- a/man/repart.d.xml +++ b/man/repart.d.xml @@ -417,6 +417,9 @@ required for the minimal file system of the specified type (or 4KiB if the minimal size is not known). + This also takes a special meta value empty. If specified this is equivalent + to specifying Label=_empty and NoAuto=1. + This option has no effect if the partition already exists. Similarly to the behaviour of CopyBlocks=, the file system is formatted diff --git a/src/repart/repart.c b/src/repart/repart.c index 76253c4a389..352384bfc0d 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -2633,6 +2633,19 @@ static int partition_read_definition(Partition *p, const char *path, const char } } + if (streq_ptr(p->format, "empty")) { + p->format = mfree(p->format); + + if (p->no_auto < 0) + p->no_auto = true; + + if (!p->new_label) { + p->new_label = strdup("_empty"); + if (!p->new_label) + return log_oom(); + } + } + if (p->minimize != MINIMIZE_OFF && !p->format && p->verity != VERITY_HASH) return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EINVAL), "Minimize= can only be enabled if Format= or Verity=hash are set."); -- 2.47.3