Closed Yurii-huang closed 2 months ago
Does anyone know why this is, maxPartitionLength means end - start + 1?
when I tried:
table_max_length = device.format.parted_disk.maxPartitionLength - 1
The result is still "requested size exceeds maximum allowed"
@vojtechtrefny Can you answer this question? thanks.
From your screenshot the partition you are trying to create is actually too long:
geom = parted.Geometry(device=device, start=2048, end=4294969343)
geom.length
4294967296
which does exceed the maximum length of 4294967295
.
When calculating the sizes in sectors don't forget that both the end and start sectors are part of the partition so a theoretical partition that starts on sector 1 and ends on sector 2 is 2 sectors long. So the length calculation length = end - start + 1 is correct.
when I tried: table_max_length = device.format.parted_disk.maxPartitionLength - 1 The result is still "requested size exceeds maximum allowed"
Do you know how the final geometry actually looks in this case? Is it possible this size is aligned up by the following code?
if not end_alignment.isAligned(free, end):
end = end_alignment.alignUp(free, end)
log.debug("adjusted length from %d to %d", length, end - start + 1)
From your screenshot the partition you are trying to create is actually too long:
geom = parted.Geometry(device=device, start=2048, end=4294969343) geom.length 4294967296
which does exceed the maximum length of
4294967295
.When calculating the sizes in sectors don't forget that both the end and start sectors are part of the partition so a theoretical partition that starts on sector 1 and ends on sector 2 is 2 sectors long. So the length calculation length = end - start + 1 is correct.
when I tried: table_max_length = device.format.parted_disk.maxPartitionLength - 1 The result is still "requested size exceeds maximum allowed"
Do you know how the final geometry actually looks in this case? Is it possible this size is aligned up by the following code?
if not end_alignment.isAligned(free, end): end = end_alignment.alignUp(free, end) log.debug("adjusted length from %d to %d", length, end - start + 1)
Thanks for the reading, this problem has been solved.
sector alignment should be applied sector rather than byte size, this is an obvious rule, and my code does byte conversion first and then sector alignment, which is not right.
Sector alignment should precede the code logic for byte conversion.
disk label seted msdos
I use the maximum size of the disk partition as the number of sectors I can allocate:
I'm doing the alignment and sector conversion in the same way as in the add_partition function
My intention is not to let him show the error "requested size exceeds maximum allowed"
Does anyone know why this is, maxPartitionLength means end - start + 1?