Bug#798465: grub-installer: Please show size as well as the device id when selecting target
Package: grub-installer
Version: 1.126
Severity: wishlist
Tags: patch
Hi,
On a recent install, I had to switch to the console during the as the
/dev/sdX names and device IDs were not sufficient for me to be 100% sure
I was installing grub to the right device.
Showing the device sizes would have been enough for me to avoid this (as
the sizes were widely different), and would provide a reassurance in
other cases where I was merely slightly uncertain.
Patch attached. I've retained the double-space between the device path
and the start of the metadata. Example screenshot here:
http://i.imgur.com/JSXrJ48.png
Regards,
--
,''`.
: :' : Chris Lamb
`. `'` lamby@debian.org / chris-lamb.co.uk
`-
diff --git a/grub-installer b/grub-installer
index c407cd1..e340e1b 100755
--- a/grub-installer
+++ b/grub-installer
@@ -222,6 +222,11 @@ devices_to_ids()
echo "$ids"
}
+convert_to_megabytes() {
+ local size="$1"
+ expr 0000000"$size" : '0*\(..*\)......$'
+}
+
rootfs=$(findfs /)
bootfs=$(findfs /boot)
[ -n "$bootfs" ] || bootfs="$rootfs"
@@ -634,7 +639,7 @@ db_progress INFO grub-installer/progress/step_bootdev
select_bootdev() {
debug "select_bootdev: arg='$1'"
- local dev_list dev_descr grubdev devices disk_id dev descr
+ local dev_list dev_descr grubdev devices disk_id dev descr devinfo devsize
local default_choice chosen result
result=""
@@ -652,13 +657,14 @@ select_bootdev() {
disk_id="$(device_to_id $grubdev)"
dev="$(readlink -f "$disk_id")"
dev_list="${dev_list:+$dev_list, }$dev"
+ devinfo=""
descr="$(echo $disk_id |sed -e 's+^.*/++' |sed -e 's+,+\\,+g')"
- if [ "$dev" = "$disk_id" ]; then
- dev_descr="${dev_descr:+$dev_descr, }$dev"
- else
- #/dev/sdX (id)
- dev_descr="${dev_descr:+$dev_descr, }$dev ($descr)"
+ if [ "$dev" != "$disk_id" ]; then
+ devinfo="${devinfo:+$devinfo\, }$descr"
fi
+ devsize="$(blockdev --getsize64 "$dev")"
+ devinfo="${devinfo:+$devinfo\, }$(convert_to_megabytes "$devsize")MB"
+ dev_descr="${dev_descr:+$dev_descr, }$dev${devinfo:+ ($devinfo)}"
done
debug "Bootdev Choices: '$dev_list'"
Reply to: