]> git.ipfire.org Git - thirdparty/systemd.git/commit
repart: Correctly handle btrfs compression (#39597)
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 9 Nov 2025 16:52:19 +0000 (01:52 +0900)
committerGitHub <noreply@github.com>
Sun, 9 Nov 2025 16:52:19 +0000 (01:52 +0900)
commit445b7073c7b6ddac9d033ff9cb83c6aeb5712923
tree35dcf99d6e52af86932de94aa264c1558be75619
parentb3c117172fdc91ce2f38ebe325eb8cb8ab57a2e2
parent2091caddb85a0816893ea5901e6d583f93d1d7f2
repart: Correctly handle btrfs compression (#39597)

systemd-repart is incorrectly choosing the loop-mount
code path to copy files after formatting, instead of using the --rootdir
path, which is required by mkfs.btrfs to apply compression (since it's
on files, not the fs).

So two fixes (and an integ test):

1. If Btrfs compression is requested without a root directory (e.g.,
Compression= without CopyFiles=), we now log a warning and skip the
--compress flag. This prevents the mkfs.btrfs failure, and it's
meaningless anyway without any files.
2. The logic in repart now uses the --rootdir code path whenever the
partition is btrfs and compression is requested. Otherwise it still
won't work even in the legitimate case because use the loop mounting
code, which is too late to use --compress.

Fixes: https://github.com/systemd/systemd/issues/39584