sgdisk - Unexpected Behavior with Decimal Point in Partition Size Specification
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
gdisk (Ubuntu) | Status tracked in Mantic | |||||
Focal |
Triaged
|
Undecided
|
Unassigned | |||
Jammy |
Triaged
|
Undecided
|
Unassigned | |||
Lunar |
Triaged
|
Undecided
|
Unassigned | |||
Mantic |
Triaged
|
Undecided
|
Unassigned |
Bug Description
When using the sgdisk command to create a new partition with a specified size, the tool behaves unexpectedly when a size is specified with a decimal point. Specifically, using a size like 7.5G results in the partition size being set to 3.5 KiB instead.
Steps to Reproduce:
Run the following command to create a partition:
sgdisk --new=1:0:+7.5G --typecode=1:8300 --change-
Verify the size of the newly created partition using sgdisk --print /dev/sda.
Expected Behavior:
The partition size should be set to 7.5 gigabytes, as specified in the --new command.
Actual Behavior:
The partition size is set to 3.5 KiB.
Additional Information:
The issue can be worked around by specifying the size in megabytes, such as 7500M.
System Information:
Operating System: Ubuntu 22.04.3 LTS
sgdisk Version: GPT fdisk (sgdisk) version 1.0.8
This is fixed in an upstream commit:
https:/ /sourceforge. net/p/gptfdisk/ code/ci/ e1cc654ef71996d 836c5d051278130 f50f768f84/ tree/
This commit causes input to be truncated to the nearest whole value; e.g., "+7.5G" becomes "+7G". Decimal processing would be imprecise and/or would add code that might hide more bugs. If that level of precision is needed, then using a lower unit (e.g., M or K rather than G) is more appropriate.
The upstream commit will eventually be released, presumably as version 1.0.10, but it's not out yet. Note that the current released version of GPT fdisk is 1.0.9, released in April of 2022; version 1.0.8 is out of date, although it was current as of Ubuntu 22.04's release.