** Description changed:

- 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.
+ [ Impact ] 
+ When creating a partition with sgdisk, if you provide a decimal input it will
+ be incorrectly interpreted. For example, putting in the command
+ sgdisk --new=1:0:+7.5G --typecode=1:8300 ./a.img to create a 7.5G partition,
+ the tool will actually create a 3.5K partition.
+ 
+ [ Test Plan ]
+ $ lxc launch ubuntu:jammy j
+ $ lxc shell j
+ # apt update -y && apt upgrade -y
+ # apt install -y gdisk
+ # fallocate -l 10G a.img
+ # sgdisk --new=1:0:+7.5G --typecode=1:8300 ./a.img
+ # fdisk -l ./a.img | grep filesystem | awk '{print $5}'
+ 3.5K
+ 
+ (Test Fix Jammy)
+ # add-apt-repository ppa:mitchdz/lp2039594-gdisk-decimal
+ # apt install -y gdisk
+ # dpkg -s gdisk | grep Version:
+ Version: 1.0.8-4ubuntu1~jammy1
+ # rm ./a.img
+ # fallocate -l 10G a.img
+ # sgdisk --new=1:0:+7.5G --typecode=1:8300 ./a.img
+ # fdisk -l ./a.img | grep filesystem | awk '{print $5}'
+ 7G
+ 
+ ( Test Fix focal)
+ # add-apt-repository ppa:mitchdz/lp2039594-gdisk-decimal
+ # apt install -y gdisk
+ # dpkg -s gdisk | grep Version:
+ Version: 1.0.5-1focal1~focal1
+ # rm ./a.img
+ # fallocate -l 10G a.img
+ # sgdisk --new=1:0:+7.5G --typecode=1:8300 ./a.img
+ # fdisk -l ./a.img | grep filesystem | awk '{print $5}'
+ 7G
+ 
+ [ Where problems could occur ]
+ * Some tool could be used to this behavior and fixing this could cause what is
+   assumed to be a regression.
+ * Adds a new while loop, while potentially negligible, will use more CPU 
cycles.
+ 
+ [Original Bug Descriptio]
+ 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:
+     Run the following command to create a partition:
  
-     sgdisk --new=1:0:+7.5G --typecode=1:8300 --change-name=1:boot
+     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
+     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,
+     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
+     Operating System: Ubuntu 22.04.3 LTS
+     sgdisk Version: GPT fdisk (sgdisk) version 1.0.8

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2039594

Title:
  sgdisk - Unexpected Behavior with Decimal Point in Partition Size
  Specification

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdisk/+bug/2039594/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to