Package: parted Version: 3.4-1 Severity: important X-Debbugs-Cc: freedombox-disc...@alioth-lists.debian.net
I first noticed this when trying to make an improvement to freedom-maker, hence FB-discuss in CC, while this issue didn't present itself with the Raspberry Pi image specs project. The former uses 'mib', while the latter uses '%'. To demonstrate it, I created a script to prove the issue: ================================================== #!/bin/sh BUILD_DIR="temp" IMAGE_NAME="parted-test.img" IMAGE_PATH="$BUILD_DIR/$IMAGE_NAME" IMAGE_SIZE="100M" echo "BUILD_DIR: $BUILD_DIR" echo "IMAGE_NAME: $IMAGE_NAME" echo "IMAGE_PATH: $IMAGE_PATH" echo "IMAGE_SIZE: $IMAGE_SIZE" if [ ! -d "$BUILD_DIR" ] ; then echo "directory $BUILD_DIR doesn't exist; create it" mkdir $BUILD_DIR fi echo "Creating image at '$IMAGE_PATH' of size '$IMAGE_SIZE'" qemu-img create -f raw "$IMAGE_PATH" "$IMAGE_SIZE" echo "Image file created" echo -n "Creating partition table ... " /sbin/parted -s $IMAGE_PATH mklabel msdos echo "Done" echo -n "Creating 1st partition ('4mib' '20%') ... " /sbin/parted -s $IMAGE_PATH mkpart primary fat32 '4mib' '20%' echo "Done" echo -n "Creating 2nd partition ('20%' '40%' ... " /sbin/parted -s $IMAGE_PATH mkpart primary ext4 '20%' '40%' echo "Done" echo -n "Creating 3rd partition ('40mib' '60mib') ... " /sbin/parted -s $IMAGE_PATH mkpart primary ext4 '40mib' '60mib' echo "Done" echo "" echo "Showing partition layout" /sbin/fdisk -l $IMAGE_PATH echo "" echo -n "Creating 4th partition ('60mib' '100%' ... " /sbin/parted -s $IMAGE_PATH mkpart primary ext4 '60mib' '100%' echo "Done" ================================================== And when I run that, I get this output: ================================================== diederik@bagend:~/tmp/parted$ ./parted-bug-test.sh BUILD_DIR: temp IMAGE_NAME: parted-test.img IMAGE_PATH: temp/parted-test.img IMAGE_SIZE: 100M directory temp doesn't exist; create it Creating image at 'temp/parted-test.img' of size '100M' Formatting 'temp/parted-test.img', fmt=raw size=104857600 Image file created Creating partition table ... Done Creating 1st partition ('4mib' '20%') ... Done Creating 2nd partition ('20%' '40%' ... Done Creating 3rd partition ('40mib' '60mib') ... Done Showing partition layout Disk temp/parted-test.img: 100 MiB, 104857600 bytes, 204800 sectors 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: 0x98f2bc17 Device Boot Start End Sectors Size Id Type temp/parted-test.img1 8192 40959 32768 16M c W95 FAT32 (LBA) temp/parted-test.img2 40960 81919 40960 20M 83 Linux temp/parted-test.img3 81920 122880 40961 20M 83 Linux Creating 4th partition ('60mib' '100%' ... Error: You requested a partition from 62.9MB to 105MB (sectors 122880..204799). The closest location we can manage is 62.9MB to 105MB (sectors 122881..204799). Done ================================================== As the image size is (deliberately) 100M, one can swap the 'mib' and '%' values. While it should produce the same output, it does not. I (strongly) believe that with 'mib' the partition is created 1 sector too large, hence the off-by-one in the subject. Consequently, when the 'end' parameter is defined in 'mib' and then try to create a new partition that starts at the previous end value, the partition creation fails. It looks like bug #902224 is related to it and possible also #835172. Cheers, Diederik -- System Information: Debian Release: 11.0 APT prefers unstable-debug APT policy: (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'unstable'), (500, 'testing'), (101, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-6-amd64 (SMP w/16 CPU threads) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages parted depends on: ii libc6 2.31-12 ii libparted2 3.4-1 ii libreadline8 8.1-1 ii libtinfo6 6.2+20201114-2 parted recommends no packages. Versions of packages parted suggests: ii parted-doc 3.4-1 -- no debconf information