mirror of
https://github.com/systemd/systemd.git
synced 2026-08-10 17:14:31 +00:00
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.