[Freedombox-discuss] Fwd: Inconsistent behavior creating partitions with 'Xmib' and 'X%' (off-by-1 error?)

Diederik de Haas didi.debian at cknow.org
Sun Aug 22 19:53:05 BST 2021


Control: forwarded -1 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21136

I tried to forward this bug to the upstream bug-parted at gnu.org ML to get some 
progress and I've 'attached' that to this bug report.

It turns out there's an upstream bug #21136 from July 2015 about this issue.
The bug is still present, but apparently there's a difference in behavior when 
using 'mib' vs 'MiB' where the latter (probably) does the right thing.

I've also attached the MiB variant here, which I hadn't included (bc not 
written yet) in the upstream report. I've made a slight change due to qemu's 
100M != parted 100MiB, by creating a 101M image and then it did succeed.

Cheers,
  Diederik

----------  Forwarded Message  ----------

Subject: Fwd: Inconsistent behavior creating partitions with 'Xmib' and 'X%' 
(off-by-1 error?)
Date: zondag 22 augustus 2021, 20:39:40 CEST
From: Diederik de Haas <didi.debian at cknow.org>
To: 21136 at debbugs.gnu.org

I send the msg below to the bug-parted at gnu.org list, but I'm not sure it 
arrived.
https://lists.gnu.org/archive/html/bug-parted/ are refreshed every 15 minutes, 
but after > 30 minutes, it hadn't shown up.

Then I searched the bug-parted archive and found bug #21136 which seems VERY 
related to my issue. Sorry for not searching first.

I made a copy of the 'parted-bug-test-mb.sh' script and replaced 'mib' with 
'MiB' and that went better, although it too failed to create the 4th 
partition, but that's likely due to qemu's 100M != 100MiB according to parted.

So it seems like the bug is still present in 3.4.

----------  Forwarded Message  ----------

Subject: Inconsistent behavior creating partitions with 'Xmib' and 'X%' (off-
by-1 error?)
Date: zondag 22 augustus 2021, 19:59:06 CEST
From: Diederik de Haas <didi.debian at cknow.org>
To: bug-parted at gnu.org

[I'm not sure this is the appropriate place/way and if not, apologies, and can 
you point me to the right place/way]

Hi,

This is a forward of https://bugs.debian.org/988146 where I reported that 
partitions were created differently when using 'mib' unit vs '%' unit.

To demonstrate it, I created 3 scripts which creates a 100MB image and do the 
partitioning within that. 
When reporting the Debian bug, I only had the mixed test and 'parted-bug-test-
mixed.sh' is identical to the one attached here, apart from an 'else' clause 
which explicitly deletes a prior created image.

In parted-bug-test-mixed.sh, I mixed 'mib' and '%' and due to the 100MB, that 
should've worked, but it did not.

When using only 'mib' then the script fails too.
When using only '%' then the script succeeds.

I think parted does the right thing when using '%'.

Relevant portion of output when running the mixed script:
=======================================================
Creating partition table ... Done
Creating 1st partition ('4mib' '20%') ... Done
Creating 2nd partition ('20%' '40%' ... Done
Creating 3rd partition ('40mib' '60mib') ... Done

Showing partition layout
Disk temp/parted-test.img: 100 MiB, 104857600 bytes, 204800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x03f77810

Device                Boot Start    End Sectors Size Id Type
temp/parted-test.img1       8192  40959   32768  16M  c W95 FAT32 (LBA)
temp/parted-test.img2      40960  81919   40960  20M 83 Linux
temp/parted-test.img3      81920 122880   40961  20M 83 Linux

Creating 4th partition ('60mib' '100%' ... Error: You requested a partition 
from 62,9MB to 105MB (sectors 122880..204799).
The closest location we can manage is 62,9MB to 105MB (sectors 
122881..204799).
=======================================================

Cheers,
  Diederik
-----------------------------------------
-----------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parted-bug-test-mb.sh
Type: application/x-shellscript
Size: 1304 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/freedombox-discuss/attachments/20210822/e22866c9/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parted-bug-test-perc.sh
Type: application/x-shellscript
Size: 1274 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/freedombox-discuss/attachments/20210822/e22866c9/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parted-bug-test-mixed.sh
Type: application/x-shellscript
Size: 1291 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/freedombox-discuss/attachments/20210822/e22866c9/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parted-bug-test-MiB.sh
Type: application/x-shellscript
Size: 1305 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/freedombox-discuss/attachments/20210822/e22866c9/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part.
URL: <http://alioth-lists.debian.net/pipermail/freedombox-discuss/attachments/20210822/e22866c9/attachment.sig>


More information about the Freedombox-discuss mailing list