From 6b5fe5d75e760bb554fb1c39c6bb874d18f1524f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 15 Nov 2023 11:14:39 +0100 Subject: [PATCH] gpt-auto-generator: hook in "growfs" for the root fs if the GPT flag 59 says so Fixes: #29791 --- src/gpt-auto-generator/gpt-auto-generator.c | 34 +++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index b2c78ef4c2b..a0c5a733cb1 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -665,6 +665,33 @@ static int add_partition_root_rw(DissectedPartition *p) { return 0; } +static int add_partition_root_growfs(DissectedPartition *p) { + + assert(p); + assert(!in_initrd()); + + /* Invoked on the main system (not initrd), to honour GPT flag 59 on the root fs (growfs) */ + + if (!p->growfs) { + log_debug("Root partition not marked for growing the file system in the GPT partition table, not generating drop-in for systemd-growfs-root.service."); + return 0; + } + + return generator_hook_up_growfs(arg_dest, "/", SPECIAL_LOCAL_FS_TARGET); +} + +static int add_partition_root_flags(DissectedPartition *p) { + int r = 0; + + assert(p); + assert(!in_initrd()); + + RET_GATHER(r, add_partition_root_growfs(p)); + RET_GATHER(r, add_partition_root_rw(p)); + + return r; +} + #if ENABLE_EFI static int add_root_cryptsetup(void) { #if HAVE_LIBCRYPTSETUP @@ -710,8 +737,9 @@ static int add_root_mount(void) { return r; } - /* Note that we do not need to enable systemd-remount-fs.service here. If - * /etc/fstab exists, systemd-fstab-generator will pull it in for us. */ + /* Note that we do not need to enable systemd-remount-fs.service here. If /etc/fstab exists, + * systemd-fstab-generator will pull it in for us, and otherwise add_partition_root_flags() will do + * it, after the initrd transition. */ r = partition_pick_mount_options( PARTITION_ROOT, @@ -860,7 +888,7 @@ static int enumerate_partitions(dev_t devnum) { "var-tmp", "/var/tmp", "Temporary Data Partition")); if (m->partitions[PARTITION_ROOT].found) - RET_GATHER(r, add_partition_root_rw(m->partitions + PARTITION_ROOT)); + RET_GATHER(r, add_partition_root_flags(m->partitions + PARTITION_ROOT)); return r; } -- 2.39.2