GNU bug report logs - #20909
incorrect partition size calculation

Previous Next

Package: parted;

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

Date: Sat, 27 Jun 2015 06:00:12 UTC

Severity: normal

Done: Phil Susi <psusi <at> ubuntu.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 20909 in the body.
You can then email your comments to 20909 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#20909; Package parted. (Sat, 27 Jun 2015 06:00:12 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. (Sat, 27 Jun 2015 06:00:13 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: Sat, 27 Jun 2015 05:19:03 +0300
Hello, All!

incorrect partition size calculation

# parted -v
parted (GNU parted) 2.3

Model: ATA HGST HUS724040AL (scsi)
Disk /dev/sda: 7814037168s

how to reproduce:

parted -s /dev/sda mklabel gpt
parted -s /dev/sda -a none mkpart primary 34s 2047s
parted -s /dev/sda set 1 bios_grub on
parted -s /dev/sda mkpart primary 2048s 2099199s
parted -s /dev/sda set 2 raid on
parted -s /dev/sda mkpart primary 2099200s 102764543s
parted -s /dev/sda set 3 raid on
parted -s /dev/sda mkpart primary zfs 102764544s 7814037134s

parted
(parted) unit s
(parted) print free
Model: ATA HGST HUS724040AL (scsi)
Disk /dev/sda: 7814037168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start       End          Size         File system  Name     Flags
 1      34s         2047s        2014s                     primary 
bios_grub
 2      2048s       2099199s     2097152s                  primary  raid
 3      2099200s    102764543s   100665344s                primary  raid
 4      102764544s  7814037134s  7711272591s               primary

(parted)

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

parted reports what /dev/sda4 partition has size of 7711272591s
but this is not true, partition size is 7711272590s:

7814037168 - 2014 -  2097152 - 100665344 - 34 - 34 == 7711272590

P.S.

sorry, I can't find bugzilla for parted and can't check
what this bug for parted was previously reported and fixed.

-- 
Best regards,
 Gena




Information forwarded to bug-parted <at> gnu.org:
bug#20909; Package parted. (Mon, 29 Jun 2015 17:44:02 GMT) Full text and rfc822 format available.

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

From: "Brian C. Lane" <bcl <at> redhat.com>
To: bug-parted <at> gnu.org
Subject: Re: bug#20909: incorrect partition size calculation
Date: Mon, 29 Jun 2015 10:43:36 -0700
On Sat, Jun 27, 2015 at 05:19:03AM +0300, Gena Makhomed wrote:
> Hello, All!
> 
> incorrect partition size calculation
> 
> # parted -v
> parted (GNU parted) 2.3
> 
> Model: ATA HGST HUS724040AL (scsi)
> Disk /dev/sda: 7814037168s
> 
> how to reproduce:
> 
> parted -s /dev/sda mklabel gpt
> parted -s /dev/sda -a none mkpart primary 34s 2047s
> parted -s /dev/sda set 1 bios_grub on
> parted -s /dev/sda mkpart primary 2048s 2099199s
> parted -s /dev/sda set 2 raid on
> parted -s /dev/sda mkpart primary 2099200s 102764543s
> parted -s /dev/sda set 3 raid on
> parted -s /dev/sda mkpart primary zfs 102764544s 7814037134s
> 
> parted
> (parted) unit s
> (parted) print free
> Model: ATA HGST HUS724040AL (scsi)
> Disk /dev/sda: 7814037168s
> Sector size (logical/physical): 512B/512B
> Partition Table: gpt
> 
> Number  Start       End          Size         File system  Name     Flags
>  1      34s         2047s        2014s                     primary bios_grub
>  2      2048s       2099199s     2097152s                  primary  raid
>  3      2099200s    102764543s   100665344s                primary  raid
>  4      102764544s  7814037134s  7711272591s               primary
> 
> (parted)
> 
> =======================================
> 
> parted reports what /dev/sda4 partition has size of 7711272591s
> but this is not true, partition size is 7711272590s:
> 
> 7814037168 - 2014 -  2097152 - 100665344 - 34 - 34 == 7711272590

You are off by 1. start and end are inclusive so the size of sda4 is:

1 + (7814037134 - 102764544) = 7711272591

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)




Information forwarded to bug-parted <at> gnu.org:
bug#20909; Package parted. (Mon, 29 Jun 2015 18:39:02 GMT) Full text and rfc822 format available.

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

From: Gena Makhomed <gmm <at> csdoc.com>
To: bug-parted <at> gnu.org
Subject: Re: bug#20909: incorrect partition size calculation
Date: Mon, 29 Jun 2015 21:37:34 +0300
On 29.06.2015 20:43, Brian C. Lane wrote:

>> incorrect partition size calculation
>>
>> # parted -v
>> parted (GNU parted) 2.3
>>
>> Model: ATA HGST HUS724040AL (scsi)
>> Disk /dev/sda: 7814037168s
>>
>> how to reproduce:
>>
>> parted -s /dev/sda mklabel gpt
>> parted -s /dev/sda -a none mkpart primary 34s 2047s
>> parted -s /dev/sda set 1 bios_grub on
>> parted -s /dev/sda mkpart primary 2048s 2099199s
>> parted -s /dev/sda set 2 raid on
>> parted -s /dev/sda mkpart primary 2099200s 102764543s
>> parted -s /dev/sda set 3 raid on
>> parted -s /dev/sda mkpart primary zfs 102764544s 7814037134s
>>
>> parted
>> (parted) unit s
>> (parted) print free
>> Model: ATA HGST HUS724040AL (scsi)
>> Disk /dev/sda: 7814037168s
>> Sector size (logical/physical): 512B/512B
>> Partition Table: gpt
>>
>> Number  Start       End          Size         File system  Name     Flags
>>   1      34s         2047s        2014s                     primary bios_grub
>>   2      2048s       2099199s     2097152s                  primary  raid
>>   3      2099200s    102764543s   100665344s                primary  raid
>>   4      102764544s  7814037134s  7711272591s               primary
>>
>> (parted)
>>
>> =======================================
>>
>> parted reports what /dev/sda4 partition has size of 7711272591s
>> but this is not true, partition size is 7711272590s:
>>
>> 7814037168 - 2014 -  2097152 - 100665344 - 34 - 34 == 7711272590
>
> You are off by 1. start and end are inclusive so the size of sda4 is:
>
> 1 + (7814037134 - 102764544) = 7711272591
>

yes, you are right, sorry.
7814037168 - 2014 -  2097152 - 100665344 - 33 - 33 -1 == 7711272591

2014s,  2097152s, 100665344s and 7711272591s is size of partitions,
1s size of MBR and 33s + 33s is size of two copies of GPT.

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.

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.

if use common scheme as in java - start index inclusive
and end index exclusive, - disk partitioning
will be very easy and obvious:

parted -s /dev/sda mkpart primary 34s 1MiB
parted -s /dev/sda mkpart primary 1MiB 1025MiB
parted -s /dev/sda mkpart primary 1025MiB 50178MiB
parted -s /dev/sda mkpart primary 50178MiB -- -34s

1-MiB alignment boundary recommended
for all GPT partitions except bios_grub one,
which contains core.img for read-only access:
https://en.wikipedia.org/wiki/BIOS_boot_partition

-- 
Best regards,
 Gena




Reply sent to Phil Susi <psusi <at> ubuntu.com>:
You have taken responsibility. (Thu, 02 Jul 2015 18:04:02 GMT) Full text and rfc822 format available.

Notification sent to Gena Makhomed <gmm <at> csdoc.com>:
bug acknowledged by developer. (Thu, 02 Jul 2015 18:04:03 GMT) Full text and rfc822 format available.

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

From: Phil Susi <psusi <at> ubuntu.com>
To: 20909-done <at> debbugs.gnu.org
Subject: Re: bug#20909: incorrect partition size calculation
Date: Thu, 02 Jul 2015 14:02:14 -0400
On 6/29/2015 2:37 PM, Gena Makhomed wrote:
>> You are off by 1. start and end are inclusive so the size of sda4 is:
>>
>> 1 + (7814037134 - 102764544) = 7711272591
>>

Closing for this reason.

> 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.

> 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.





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

This bug report was last modified 10 years and 19 days ago.

Previous Next


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