GNU bug report logs - #21136
incorrect partition size calculation

Previous Next

Package: parted;

Reported by: Gena Makhomed <gmm <at> csdoc.com>

Date: Sun, 26 Jul 2015 17:02:01 UTC

Severity: normal

Done: "Brian C. Lane" <bcl <at> redhat.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21136 in the body.
You can then email your comments to 21136 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-parted <at> gnu.org:
bug#21136; Package parted. (Sun, 26 Jul 2015 17:02:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gena Makhomed <gmm <at> csdoc.com>:
New bug report received and forwarded. Copy sent to bug-parted <at> gnu.org. (Sun, 26 Jul 2015 17:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gena Makhomed <gmm <at> csdoc.com>
To: bug-parted <at> gnu.org
Subject: incorrect partition size calculation
Date: Sun, 26 Jul 2015 20:01:39 +0300
On 02.07.2015 21:02, Phil Susi wrote:

>> BTW, "start and end are inclusive" - IMHO is very bad decision,
>> because now it is not possible to partition disk using MiB units
>> and always need use sectors and make all calculations manually.
>
> No.. MiB units work just fine.

I am just tested again on parted version 3.1
- it uses one more sector in case of "mib" unit.

>> for example, parted -s /dev/sda mkpart primary 34s 1MiB
>> now use one sector from second MiB and next partition
>> will be created as unaligned.
>
> No, it doesn't... the partition ends on sector 2047, so the next
> partition can start on sector 2048.

steps to reproduce bug:

Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End        Size       File system  Name     Flags
 1      34s    2047s      2014s                   primary  bios_grub
        2048s  67108822s  67106775s  Free Space

if I issue command "mkpart primary 1MiB 8193MiB" - all works fine:

Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start      End        Size       File system  Name     Flags
 1      34s        2047s      2014s                   primary  bios_grub
 2      2048s      16779263s  16777216s               primary
        16779264s  67108822s  50329559s  Free Space

but if I issue command "mkpart primary 1mib 8193mib" - BUG IS HERE:

Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start      End        Size       File system  Name     Flags
 1      34s        2047s      2014s                   primary  bios_grub
 2      2048s      16779264s  16777217s               primary
        16779265s  67108822s  50329558s  Free Space

==============================================================

difference only in unit name case: 'MiB' works fine,
'mib' create wrong partitions, used one more sector.

looks like this is bug, and behavior of parted
should be the same, regardless of unit name case: 'mib' or 'MiB'.

-- 
Best regards,
 Gena




Information forwarded to bug-parted <at> gnu.org:
bug#21136; Package parted. (Fri, 18 Sep 2015 18:32:01 GMT) Full text and rfc822 format available.

Message #8 received at 21136 <at> debbugs.gnu.org (full text, mbox):

From: Phil Susi <psusi <at> ubuntu.com>
To: Gena Makhomed <gmm <at> csdoc.com>, 21136 <at> debbugs.gnu.org
Subject: Re: bug#21136: incorrect partition size calculation
Date: Fri, 18 Sep 2015 14:31:43 -0400
On 7/26/2015 1:01 PM, Gena Makhomed wrote:
> I am just tested again on parted version 3.1
> - it uses one more sector in case of "mib" unit.

Ahh, the case matters.. very strange.






Information forwarded to bug-parted <at> gnu.org:
bug#21136; Package parted. (Sun, 22 Aug 2021 23:41:02 GMT) Full text and rfc822 format available.

Message #11 received at 21136 <at> debbugs.gnu.org (full text, mbox):

From: Diederik de Haas <didi.debian <at> cknow.org>
To: 21136 <at> debbugs.gnu.org
Subject: Fwd: Inconsistent behavior creating partitions with 'Xmib' and 'X%'
 (off-by-1 error?)
Date: Sun, 22 Aug 2021 20:39:40 +0200
[Message part 1 (text/plain, inline)]
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
-----------------------------------------
[parted-bug-test-mb.sh (application/x-shellscript, attachment)]
[parted-bug-test-perc.sh (application/x-shellscript, attachment)]
[parted-bug-test-mixed.sh (application/x-shellscript, attachment)]
[signature.asc (application/pgp-signature, inline)]

Reply sent to "Brian C. Lane" <bcl <at> redhat.com>:
You have taken responsibility. (Thu, 26 Aug 2021 21:34:01 GMT) Full text and rfc822 format available.

Notification sent to Gena Makhomed <gmm <at> csdoc.com>:
bug acknowledged by developer. (Thu, 26 Aug 2021 21:34:01 GMT) Full text and rfc822 format available.

Message #16 received at 21136-close <at> debbugs.gnu.org (full text, mbox):

From: "Brian C. Lane" <bcl <at> redhat.com>
To: 21136-close <at> debbugs.gnu.org
Subject: Re: bug#21136: Fwd: Inconsistent behavior creating partitions with
 'Xmib' and 'X%' (off-by-1 error?)
Date: Thu, 26 Aug 2021 14:33:20 -0700
-- 
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 24 Sep 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 219 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.