Re: Bug#1098638: fdisk: creates partitions one sector too large

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 25 Feb 2025, Karel Zak wrote:

>The convention of +<sectors> is strictly evaluated as <first> + <size>,
>without subtracting 1.

I guess someone made the maths mistake here: the last sector
is always <first> + <size> - 1, compare C arrays.

>This is how fdisk has functioned since its inception. I noticed this
>in the v2.13 code and was able to replicate it with v2.14 (year 2008).

Ouch. Then I agree changing this is not prudent at this point,
but please *do* clarify this in the question text. Let me
propose new text… hmm, let me see the old…

>> > Command (m for help): n
>> > Partition number (1-128, default 1):
>> > First sector (2048-7814037134, default 2048):
>> > Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-7814037134, default 7814035455): +2097152

… let’s go multiline for this:

| Last sector (2048-7814037134, default 7814035455),
| +/-sectors from first sector, or +/-size{K,M,G,T,P}:

>This is different from +<size>{M,G,T,..} where the final
>size is reduced by 1 and aligned to the disk I/O limits.

I expected the -1 (fencepost) but not the alignment, but
that makes sense.

>Additionally, it should be noted that people use 'echo
>"something" | fdisk' in scripts ...

Indeed, I do so myself, though in scripts I have so far
always calculated the last sector manually, it was only
that day interactively when I wanted to enter a manual
size in sectors: specifically, a split-mode dm-integrity
<https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=useful-scripts/useful-scripts.git;a=blob;f=integritysetup/README.txt;h=76a7a67cb35d34c08eeeb916ce26f1832febf922;hb=HEAD#l113>
partition (where I manually aligned the result from the
isize-p script in the aforementioned documentation to a
multiple of 2048).

────────────────────────────────────────────────────────────────────────

So, would you please consider changing the wording, at
least, upstream? (And, perhaps, throw in another sentence
or two into the manpage, stating that the +sectors syntax
isn’t meant to express size, unlike the others.)

Thanks,
//mirabilos
-- 
[16:04:33] bkix: "veni vidi violini"
[16:04:45] bkix: "ich kam, sah und vergeigte"...





[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux