From: Chris Down Date: Thu, 6 Nov 2025 15:17:01 +0000 (+0800) Subject: repart: Force --rootdir population for btrfs with compression X-Git-Tag: v259-rc1~119^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f30a29245d8ff4509c95bef817944299efbc3795;p=thirdparty%2Fsystemd.git repart: Force --rootdir population for btrfs with compression When a btrfs partition is configured with both Compression= and CopyFiles=, we need to ensure files are copied during filesystem creation using mkfs.btrfs --rootdir, rather than copying files afterwards via loop device mounting. This is required because mkfs.btrfs can only apply compression settings when files are provided via --rootdir during filesystem creation. If we format the filesystem first and then mount it to copy files, the compression setting is meaningless. Modify the partition_needs_populate() condition to force the --rootdir code path when the format is btrfs and compression is requested. This ensures that partition_populate_directory() runs and creates a temporary directory with the files, which is then passed to make_filesystem() as the root parameter, allowing mkfs.btrfs to create the filesystem with compression applied. Fixes: https://github.com/systemd/systemd/issues/39584 --- diff --git a/src/repart/repart.c b/src/repart/repart.c index dbf261bb262..456aed41bd7 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -6785,7 +6785,8 @@ static int context_mkfs(Context *context) { * have to populate using the filesystem's mkfs's --root= (or equivalent) option. To do that, * we need to set up the final directory tree beforehand. */ - if (partition_needs_populate(p) && (!t->loop || fstype_is_ro(p->format))) { + if (partition_needs_populate(p) && + (!t->loop || fstype_is_ro(p->format) || (streq_ptr(p->format, "btrfs") && p->compression))) { if (!mkfs_supports_root_option(p->format)) return log_error_errno(SYNTHETIC_ERRNO(ENODEV), "Loop device access is required to populate %s filesystems.", @@ -8533,7 +8534,7 @@ static int context_minimize(Context *context) { return r; } - if (!d || fstype_is_ro(p->format)) { + if (!d || fstype_is_ro(p->format) || (streq_ptr(p->format, "btrfs") && p->compression)) { if (!mkfs_supports_root_option(p->format)) return log_error_errno(SYNTHETIC_ERRNO(ENODEV), "Loop device access is required to populate %s filesystems.",