]> git.ipfire.org Git - thirdparty/systemd.git/commit
repart: Don't get old grain size from fdisk for --copy-from=
authorJonas Dreßler <verdre@v0yd.nl>
Tue, 7 Jul 2026 12:41:16 +0000 (14:41 +0200)
committerJonas Dreßler <verdre@v0yd.nl>
Mon, 13 Jul 2026 10:09:13 +0000 (12:09 +0200)
commit2b1be5d909358fe883d38dcd091bc2d1ec9be8bc
treeda6a4310156d8e9db1a6cd29e44163e0fc6b3226
parent9a09141caeb45876f9258de0b96e5c09eb428648
repart: Don't get old grain size from fdisk for --copy-from=

This is a little bit confusing, but grain size is not actually stored in the gpt
metadata. Rather, fdisk's `get_grain_size()` returns an autodiscovered "optimal io
size" value as grain size. This might not actually be the grain size that the
disk we're copying is using.

Since we're setting the padding of the copied partitions using that value from
fdisk, we're rounding the new paddings by fdisk's optimal grain size, which is
usually 1MiB (a lot more then the default 4KiB that we're using otherwise).

Set the grain size here to 1 byte instead, ensuring that the min/max padding set
is exactly the padding that was present before.

Also add a test to confirm the behavior is fixed: The test calls --copy-from= on
an existing disk with 4MiB grain size, and because we pass --grain-size=512, now
no rounding should happen and the paddings should be transferred to exactly the
same size.
src/repart/repart.c
test/units/TEST-58-REPART.sh