sgdisk - Unexpected Behavior with Decimal Point in Partition Size Specification

Bug #2039594 reported by adrya
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gdisk (Ubuntu)
Triaged
Undecided
Unassigned
Focal
Triaged
Undecided
Unassigned
Jammy
Triaged
Undecided
Unassigned
Lunar
Won't Fix
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-name=1:boot /dev/sda

    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

Revision history for this message
Rod Smith (rodsmith) wrote :

This is fixed in an upstream commit:

https://sourceforge.net/p/gptfdisk/code/ci/e1cc654ef71996d836c5d051278130f50f768f84/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.

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for taking the time to report this bug.

I can confirm it on all supported Ubuntu releases (F/J/L/M). Here's the reproducer:

# fallocate -l 10G a.img
# sgdisk --new=1:0:+7.5G --typecode=1:8300 ./a.img
# fdisk -l ./a.img

I haven't tried the patch mentioned by Rod, but it does seem to address the issue.

I'll add this to our backlog.

Changed in gdisk (Ubuntu Focal):
status: New → Triaged
Changed in gdisk (Ubuntu Jammy):
status: New → Triaged
Changed in gdisk (Ubuntu Lunar):
status: New → Triaged
Changed in gdisk (Ubuntu Mantic):
status: New → Triaged
Revision history for this message
Brian Murray (brian-murray) wrote :

Ubuntu 23.04 (Lunar Lobster) has reached end of life, so this bug will not be fixed for that specific release.

Changed in gdisk (Ubuntu Lunar):
status: Triaged → Won't Fix
tags: added: server-todo
Revision history for this message
Mitchell Dzurick (mitchdz) wrote :

Rod, do you know when the presumed 1.0.10 release will come out?

Revision history for this message
Mitchell Dzurick (mitchdz) wrote :

Let's wait for this upstream fix to go into a release and then Debian can pick it up - from there, our archive will sync with Debian. I'll ask upstream to make a release.

tags: removed: server-todo
Revision history for this message
Mitchell Dzurick (mitchdz) wrote :

Made bug in sourceforge here asking for new release - https://sourceforge.net/p/gptfdisk/discussion/939590/thread/84321440ed/

Revision history for this message
Rod Smith (rodsmith) wrote :

I've released version 1.0.10 yesterday.

Revision history for this message
Mitchell Dzurick (mitchdz) wrote :

Thanks a ton Rod! Addding server-triage-discuss to get this properly tracked.

tags: added: server-triage-discuss
Revision history for this message
Bryce Harrington (bryce) wrote :

Sounds like this should be included with the next merge of this package (presumably next cycle).
Process for tracking these kinds of bugs is to tag them 'packaging'. The tooling for automatically attaching these to the generated 'needs-merge' card is not in place, so I'm also tagging *this* bug 'needs-merge' but with milestone 'later'.

tags: added: packaging
removed: server-triage-discuss
tags: added: needs-merge
Changed in gdisk (Ubuntu):
milestone: none → later
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.