instead of cutting it off by using int especially relevant currently with 2 TB disks (people wonder why it's displayed as 1 TiB - and would be fine with 1.95TiB).
Reported in our community forum: https://forum.proxmox.com/threads/.103636/ Tested in a VM with a 100 GiB, 20GiB and 2TiB disk Addtionally added the explicit return ath the end of the if branch, instead of relying on the last statement not moving. Signed-off-by: Stoiko Ivanov <s.iva...@proxmox.com> --- Alternatively we could also use sprintf without decimal places for rounding (Math::Round is a debian package of it's own) - if people consider 20.00GiB to not look too pleasing Thanks to Dominik for insisting to see the code on this and suggesting to actually improve it :) proxinstall | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/proxinstall b/proxinstall index ae0e235..a39d405 100755 --- a/proxinstall +++ b/proxinstall @@ -2554,16 +2554,16 @@ sub get_device_desc { my ($devname, $size, $model) = @_; if ($size && ($size > 0)) { - $size = int($size/2048); # size in MB, from 512B "sectors" + $size = int($size/2048); # size in MiB, from 512B "sectors" my $text = "$devname ("; if ($size >= 1024) { - $size = int($size/1024); # size in GB + $size = $size/1024; # size in GiB if ($size >= 1024) { - $size = int($size/1024); # size in GB - $text .= "${size}TiB"; + $size = $size/1024; # size in TiB + $text .= sprintf("%.2f", $size) . "TiB"; } else { - $text .= "${size}GiB"; + $text .= sprintf("%.2f", $size) . "GiB"; } } else { $text .= "${size}MiB"; @@ -2571,6 +2571,7 @@ sub get_device_desc { $text .= ", $model" if $model; $text .= ")"; + return $text; } else { return $devname; -- 2.30.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel