Re: Bug#1098638: fdisk: creates partitions one sector too large
Chris Hofstaedtler <[email protected]>
| Newsgroups | org.kernel.vger.util-linux |
|---|---|
| Message-ID | <[email protected]> |
Control: tags -1 + upstream
Looping in upstream.
On Sat, Feb 22, 2025 at 12:57:38AM +0100, Thorsten Glaser wrote:
> Package: fdisk
> Version: 2.38.1-5+deb12u1
>
> When I create a new partition with +sectors, fdisk creates one
> that is one sector too large:
>
>
> 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
>
> Created a new partition 1 of type 'Linux filesystem' and of size 1 GiB.
>
> Command (m for help): p
> Disk /dev/sdb: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
> Disk model: ST4000NM0245-1Z2
> Units: sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 4096 bytes
> I/O size (minimum/optimal): 4096 bytes / 4096 bytes
> Disklabel type: gpt
> Disk identifier: DDA88AFF-1E6A-7448-AB5A-85470938DBC7
>
> Device Start End Sectors Size Type
> /dev/sdb1 2048 2099200 2097153 1G Linux filesystem
Also from Thorsten:
> Same for MBR:
>
>
> Command (m for help): n
> Partition type
> p primary (0 primary, 0 extended, 4 free)
> e extended (container for logical partitions)
> Select (default p): p
> Partition number (1-4, default 1): 1
> First sector (2048-1000215215, default 2048):
> Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1000215215, default 1000215215): +2048
>
> Created a new partition 1 of type 'Linux' and of size 1 MiB.
>
> Command (m for help): p
> Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
> Disk model: SAMSUNG MZVLB512HBJQ-00000
> 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: 0x3cca69b4
>
> Device Boot Start End Sectors Size Id Type
> /dev/nvme0n1p1 2048 4096 2049 1M 83 Linux
I've briefly reproduced this with util-linux 2.41-rc1 on a loopdev.
From what I understand Thorsten is saying, he would expect, for a
partition that starts at sector 2048, when its created with "+2048"
size, to have a number of 2048 sectors, not 2049 as shown above.
I haven't looked at the code if this is intentional or what the
reason could be.
Best,
Chris