On Sun, Feb 23, 2025 at 02:22:21PM GMT, Chris Hofstaedtler wrote: > 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 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). The convention of +<sectors> is strictly evaluated as <first> + <size>, without subtracting 1. 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 have doubts about changing this after 20 years due to backward compatibility. Additionally, it should be noted that people use 'echo "something" | fdisk' in scripts ... Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com