Re: debian-installer: how to exactly specify partition sizes?
On 12/07/2025 at 14:03, Andy Smith wrote:
I'm still a little confused why partman alters supplied sizes that come
from something that was previously installed by partman. I was giving it
sizes that were 1-MiB aligned so I expected the first one to start 2048
sectors from the start and go on for the exact amount of bytes
specified, since those values were already aligned.
Partition creation involves two steps:
1) Calculate the desired partition start and end from the free space
range start and end, and desired position and size. This step does not
take alignement constraints into account. Basically:
switch(position)
"full":
partition start = free space start
partition end = free space end
"beginning":
partition start = free space start
partition end = free space start + desired size
"end":
partition start = free space end - desired size
partition end = free space end
2) Request the partition creation with the calculated start and end.
This step enforces alignment constraints, so the resulting start and end
may be independently adjusted to satisfy alignment constraints. Of
course this may affect the resulting partition size.
When creating the first partition at the beginning of the disk with a
GPT partition table, the free space start is 17 KiB. So the calculated
partition start will be 17 KiB, and the calculated partition end will be
(desired size + 17 KiB). Optimal alignement constraint will
independently adjust the actual start to 1 MiB and the actual end to
desired size, so the resulting size will be (desired size - 1 MiB).
The partitioning log is recorded in /var/log/partman during the installation
or in /var/log/installer/partman in the installed system.
Is there any way to use this log to feed in to another instance of
partman to replicate what was done before?
You can retrieve desired partition sizes in NEW_PARTITION command lines.
If you use them you should get the same resulting sizes.
Or can it just be used to make a preseed that would exactly replicate
it?
Do you mean with partman-auto/expert_recipe ?
Partition size unit in partman-auto recupes is decimal MB, so it may be
hard to replicate partition sizes which were given in binary units.
I did notice that the first partition I asked for by exact byte count
ended up 1 MiB smaller than I expected so I was able to replicate what
I wanted by asking for an extra 1MiB, however then I saw this didn't
hold true for the next partition. Perhaps if I had done the adjustment
for the first partition but then not for any others I would have been
able to do it?
I guess so, for primary partitions. Logical partitions would be 1 MiB
smaller than requested.
i.e. given existing partman-installed system:
$ head -6 /proc/partitions
major minor #blocks name
8 16 1875374424 sdb
8 17 487424 sdb1
8 18 976896 sdb2
8 19 1952768 sdb3
I could ask for exact sizes:
$ echo "487424*512 + 1024" | bc
249562112
$ echo "976896*512" | bc
500170752
$ echo "1952768*512" | bc
999817216
Sizes in /proc/partitions are in KiB, not 512-byte sectors.
Reply to: