Bug 1659130

Summary: parted failure when using SI units to specify start of logical partition
Product: [Fedora] Fedora Reporter: thomas.swan
Component: partedAssignee: Brian Lane <bcl>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 29CC: bcl
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-13 18:47:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description thomas.swan 2018-12-13 16:18:24 UTC
Description of problem:
When specifying partition begin and end points using si units, parted fails to create a logical partition.

Version-Release number of selected component (if applicable):
parted-3.2-36.fc29.x86_64
(unsure how far back bug goes)

How reproducible:
always

Steps to Reproduce:
1. create 10G media: file or usb
2. while read l ; do sudo parted -s /dev/sda -- $l ; done <<EOF
mklabel msdos
mkpart extended 0GiB -1s
mkpart logical ext4 0GiB 6GiB
EOF

Actual results:
Error: You requested a partition from 0.00B to 6442MB (sectors 0..12582911).
The closest location we can manage is 1024B to 6442MB (sectors 2..12582911).
FAIL

Expected results:
partition should be created a next sector


Additional info:
This happens at any boundary particularly and with an alignment option and is specific to SI unit specification.

Additional failure runs and successes:
In each of these, changing the beginning of the start position to a non-SI unit causes the program to complete without errors.

$ while read l ; do sudo parted -a none -s /dev/sda -- $l ; done <<EOF
mklabel msdos
mkpart extended 0GB -1s
mkpart logical ext4 0GiB 6GiB
set 1 boot on
EOF
Error: You requested a partition from 0.00B to 6442MB (sectors 0..12582911).
The closest location we can manage is 1024B to 6442MB (sectors 2..12582911).
FAIL

$ while read l ; do sudo parted -a none -s /dev/sda -- $l ; done <<EOF
mklabel msdos
mkpart extended 0GB -1s
mkpart logical ext4 0GB 6GiB
set 1 boot on
EOF
SUCCESS

$ while read l ; do sudo parted -a none -s /dev/sda -- $l ; done <<EOF
mklabel msdos
mkpart pri ext4 1MiB 1GiB
mkpart pri ext4 1GiB 2GiB
mkpart pri linux-swap 2GiB 4GiB
mkpart extended 4GiB -1s
mkpart logical ext4 4GB 6GiB
set 1 boot on
set 5 lvm on
EOF
SUCCESS

Comment 1 Brian Lane 2018-12-13 18:47:39 UTC
This actually isn't a bug. SI units are treated as an exact request, and snapping to the next valid sector is disabled.

This was changed in https://git.savannah.gnu.org/cgit/parted.git/commit/?id=552805a03a79f7b6badaf26536d86db580360f98

And has been present since parted 2.4