Subject: bug#21136: closed (Re: bug#21136: Fwd: Inconsistent behavior creating partitions with 'Xmib' and 'X%' (off-by-1 error?))

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 26 Aug 2021 21:34:01 +0000

Your bug report

#21136: incorrect partition size calculation

which was filed against the parted package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
21136: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21136
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#21136: Fwd: Inconsistent behavior creating partitions with 'Xmib' and 'X%' (off-by-1 error?)
From: "Brian C. Lane" <[email-masked]>
To: [email-masked]
Date: Thu, 26 Aug 2021 14:33:20 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

-- 
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart

Subject: incorrect partition size calculation
From: Gena Makhomed <[email-masked]>
To: [email-masked]
Date: Sun, 26 Jul 2015 20:01:39 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

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