Bug#982743: Hurd: grub-probe returning invalid HDD numbers for several --target options
Stephen Lyons
slysven at virginmedia.com
Sat Feb 13 20:31:03 GMT 2021
Package: grub-common
Version: 2.02-2
Severity: important
Dear Maintainer,
I have a Debian/Hurd installation on an (oversized, it is 160GB but only
138GB can, I understand, be accessed) PATA HDD - i.e. on real hardware.
It is an old Dell Dimension 5150 which is a Pentium D unit so it is a
64-Bit Dual core machine with 1GB of memory - though none of that is
really important I think.
The installation was done on another machine where - due to the vagaries
of the multiple HDD interfaces it was presenting as - as far as the
Debian Hurd Installer (the 2020/07/31 Full DVD version) was concerned
meant it was "/dev/hd2" - though it was the sole hard-drive in the
system. However - and since it was a few days ago and I have been trying
things I cannot be certain so this next bit, between lines of "+"s may
NOT be the case:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
When the installation was booted I *think* it started Grub and got to
the normal mode menu, but it wouldn't boot. I reviewed the commands that
Grub intended to perform and I spotted that instead of "hd2s1" being
used for the root device it was using "hd-47s1"! However I was able to
get it to boot by changing all those entries back to "hd2s1".
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Note that due to a second bug which I haven't yet reported, there is a
duplicate call to:
prepare_grub_to_access_device "${GRUB_DEVICE}" | grub_add_tab| sed
"s/^/$submenu_indentation/"
at around line 127 of /etc/grub.d/10_hurd which means there is a batch
of extra, duplicated, commands in the Grub menu item that - fortunately
- would seem to be idempotent but also had to be edited to correct the
bogus "hd-47s1" entries.
Moving on, I transferred the HHD to the system I am SSHing into ("hunt")
to write this and expected to need to edit the same entries to be
"hd0s1" as the drive is now the only drive and the BIOS is happy for it
to be the first drive. Once booted I was able to run grub-update and
expected that to make things work upon the next boot. However on
inspecting the Grub menu item in the new system I have found that the
"/dev/hd0" drive is being misnumbered as "hd-49". Note that the bogus
designation has changed by the same amount as the correct one:
"2" -> "-47"
"0" -> "-49"
to my mind that suggests something is doing some maths or C code to
convert between a C char type to a C int type when it shouldn't or
vise-versa. This is confirmed by the following command and its output:
> root at hunt:~# /usr/sbin/grub-probe -v -d /dev/hd0s1 -t bios_hints
> /usr/sbin/grub-probe: info: cannot open `/boot/grub/device.map': No
such file or directory.
> /usr/sbin/grub-probe: info: /dev/hd0s1 is not present.
> /usr/sbin/grub-probe: info: Looking for /dev/hd0s1.
> /usr/sbin/grub-probe: info: /dev/hd0 is a parent of /dev/hd0s1.
> /usr/sbin/grub-probe: info: /dev/hd0s1 is present.
> /usr/sbin/grub-probe: info: Looking for /dev/hd0s1.
> /usr/sbin/grub-probe: info: /dev/hd0 is a parent of /dev/hd0s1.
> /usr/sbin/grub-probe: info: /dev/hd0s1 is present.
> /usr/sbin/grub-probe: info: /dev/hd0 is a parent of /dev/hd0s1.
> /usr/sbin/grub-probe: info: opening hostdisk//dev/hd0,1.
> /usr/sbin/grub-probe: info: drive = 0.
> /usr/sbin/grub-probe: the size of hostdisk//dev/hd0 is 268435455.
> hd-49,msdos1
> root at hunt:~#
Running the same commands for the other relevant -t targets shows the
same defect.
Obviously I would have expected the outcome for this command to have
been that the output was "hd0,msdos1" rather than "hd-49.msdos1".
It seems fair to assume that this is specifically a Hurd issue and
only affecting "real" hardware...
Stephen Lyons
-- Package-specific info:
*********************** BEGIN /proc/mounts
/dev/hd0s1 / ext2fs writable,no-inherit-dir-group,store-type=typed 0 0
/dev/hd0s7 /tmp /hurd/ext2fs writable,no-inherit-dir-group 0 0
/dev/hd0s5 /var /hurd/ext2fs writable,no-inherit-dir-group 0 0
/dev/hd0s8 /home /hurd/ext2fs writable,no-inherit-dir-group 0 0
*********************** END /proc/mounts
*********************** BEGIN /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="0"
fi
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi
export menuentry_id_option
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}
if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
insmod part_msdos
insmod ext2
set root='hd-49,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd-49,msdos1
--hint-efi=hd-49,msdos1 --hint-baremetal=ata-49,msdos1
9cf22264-b7fe-4064-b971-c1c4a622bcf8
else
search --no-floppy --fs-uuid --set=root
9cf22264-b7fe-4064-b971-c1c4a622bcf8
fi
font="/usr/share/grub/unicode.pf2"
fi
if loadfont $font ; then
set gfxmode=auto
load_video
insmod gfxterm
set locale_dir=$prefix/locale
set lang=en_GB
insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ] ; then
set timeout=30
else
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=5
fi
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
insmod part_msdos
insmod ext2
set root='hd-49,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd-49,msdos1
--hint-efi=hd-49,msdos1 --hint-baremetal=ata-49,msdos1
9cf22264-b7fe-4064-b971-c1c4a622bcf8
else
search --no-floppy --fs-uuid --set=root
9cf22264-b7fe-4064-b971-c1c4a622bcf8
fi
insmod png
if background_image
/usr/share/desktop-base/futureprototype-theme/grub/grub-4x3.png; then
set color_normal=white/black
set color_highlight=black/white
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_hurd ###
menuentry 'Debian GNU/Hurd' --class debian --class gnu --class os
$menuentry_id_option 'gnuhurd-simple-9cf22264-b7fe-4064-b971-c1c4a622bcf8' {
insmod part_msdos
insmod ext2
set root='hd-49,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd-49,msdos1
--hint-efi=hd-49,msdos1 --hint-baremetal=ata-49,msdos1
9cf22264-b7fe-4064-b971-c1c4a622bcf8
else
search --no-floppy --fs-uuid --set=root
9cf22264-b7fe-4064-b971-c1c4a622bcf8
fi
echo 'Loading GNU Mach ...'
multiboot /boot/gnumach-1.8-486.gz root=device:hd0s1
insmod part_msdos
insmod ext2
set root='hd-49,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd-49,msdos1
--hint-efi=hd-49,msdos1 --hint-baremetal=ata-49,msdos1
9cf22264-b7fe-4064-b971-c1c4a622bcf8
else
search --no-floppy --fs-uuid --set=root
9cf22264-b7fe-4064-b971-c1c4a622bcf8
fi
echo 'Loading the Hurd ...'
module /hurd/ext2fs.static ext2fs --readonly \
--multiboot-command-line='${kernel-command-line}' \
--host-priv-port='${host-port}' \
--device-master-port='${device-port}' \
--exec-server-task='${exec-task}' -T typed '${root}' \
'$(task-create)' '$(task-resume)'
module /lib/ld.so.1 exec /hurd/exec '$(exec-task=task-create)'
}
submenu 'Advanced options for Debian GNU/Hurd' $menuentry_id_option
'gnuhurd-advanced-9cf22264-b7fe-4064-b971-c1c4a622bcf8' {
menuentry 'Debian GNU/Hurd, with Hurd gnumach-1.8-486.gz' --class
debian --class gnu --class os $menuentry_id_option
'gnuhurd-/boot/gnumach-1.8-486.gz-advanced-9cf22264-b7fe-4064-b971-c1c4a622bcf8'
{
insmod part_msdos
insmod ext2
set root='hd-49,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd-49,msdos1
--hint-efi=hd-49,msdos1 --hint-baremetal=ata-49,msdos1
9cf22264-b7fe-4064-b971-c1c4a622bcf8
else
search --no-floppy --fs-uuid --set=root
9cf22264-b7fe-4064-b971-c1c4a622bcf8
fi
echo 'Loading GNU Mach ...'
multiboot /boot/gnumach-1.8-486.gz root=device:hd0s1
insmod part_msdos
insmod ext2
set root='hd-49,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd-49,msdos1
--hint-efi=hd-49,msdos1 --hint-baremetal=ata-49,msdos1
9cf22264-b7fe-4064-b971-c1c4a622bcf8
else
search --no-floppy --fs-uuid --set=root
9cf22264-b7fe-4064-b971-c1c4a622bcf8
fi
echo 'Loading the Hurd ...'
module /hurd/ext2fs.static ext2fs --readonly \
--multiboot-command-line='${kernel-command-line}' \
--host-priv-port='${host-port}' \
--device-master-port='${device-port}' \
--exec-server-task='${exec-task}' -T typed '${root}' \
'$(task-create)' '$(task-resume)'
module /lib/ld.so.1 exec /hurd/exec '$(exec-task=task-create)'
}
menuentry 'Debian GNU/Hurd, with Hurd gnumach-1.8-486.gz (recovery
mode)' --class debian --class gnu --class os $menuentry_id_option
'gnuhurd-/boot/gnumach-1.8-486.gz-recovery-9cf22264-b7fe-4064-b971-c1c4a622bcf8'
{
insmod part_msdos
insmod ext2
set root='hd-49,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd-49,msdos1
--hint-efi=hd-49,msdos1 --hint-baremetal=ata-49,msdos1
9cf22264-b7fe-4064-b971-c1c4a622bcf8
else
search --no-floppy --fs-uuid --set=root
9cf22264-b7fe-4064-b971-c1c4a622bcf8
fi
echo 'Loading GNU Mach ...'
multiboot /boot/gnumach-1.8-486.gz root=device:hd0s1 -s
insmod part_msdos
insmod ext2
set root='hd-49,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd-49,msdos1
--hint-efi=hd-49,msdos1 --hint-baremetal=ata-49,msdos1
9cf22264-b7fe-4064-b971-c1c4a622bcf8
else
search --no-floppy --fs-uuid --set=root
9cf22264-b7fe-4064-b971-c1c4a622bcf8
fi
echo 'Loading the Hurd ...'
module /hurd/ext2fs.static ext2fs \
--multiboot-command-line='${kernel-command-line}' \
--host-priv-port='${host-port}' \
--device-master-port='${device-port}' \
--exec-server-task='${exec-task}' -T typed '${root}' \
'$(task-create)' '$(task-resume)'
module /lib/ld.so.1 exec /hurd/exec '$(exec-task=task-create)'
}
}
### END /etc/grub.d/10_hurd ###
### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply
type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
*********************** END /boot/grub/grub.cfg
*********************** BEGIN /proc/mdstat
cat: /proc/mdstat: No such file or directory
*********************** END /proc/mdstat
*********************** BEGIN /dev/disk/by-id
ls: cannot access '/dev/disk/by-id': No such file or directory
*********************** END /dev/disk/by-id
*********************** BEGIN /dev/disk/by-uuid
ls: cannot access '/dev/disk/by-uuid': No such file or directory
*********************** END /dev/disk/by-uuid
-- System Information:
Debian Release: bullseye/sid
Architecture: hurd-i386 (i686-AT386)
Kernel: GNU-Mach 1.8+git20200710-486/Hurd-0.9
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
Versions of packages grub-common depends on:
ii gettext-base 0.19.8.1-6
ii libc0.3 2.31-2
ii libfreetype6 2.10.2+dfsg-3
ii liblzma5 5.2.4-1+b2
Versions of packages grub-common recommends:
ii os-prober 1.77
Versions of packages grub-common suggests:
ii console-setup 1.196
ii desktop-base 10.0.3
pn grub-emu <none>
pn multiboot-doc <none>
pn xorriso <none>
-- Configuration Files:
/etc/grub.d/10_hurd changed:
set -e
prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"
. "$pkgdatadir/grub-mkconfig_lib"
CLASS="--class gnu --class os"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU
else
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' '
-f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
fi
at_least_one=false
all_of_them=true
kernel=
for i in /boot/gnumach* ; do
# Next 4 lines put in to debug things. S.L. 2021/02/13:
gettext_printf "Using %s as root device..." "${GRUB_DEVICE}" >&2
echo >&2
gettext_printf "Using %s as boot device..." "${GRUB_DEVICE_BOOT}" >&2
echo >&2
if test -e $i ; then
basename=`basename $i`
dirname=`dirname $i`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
gettext_printf "Found GNU Mach: %s" "$i" >&2
echo >&2
kernels="${kernels} ${rel_dirname}/${basename}"
at_least_one=true
fi
done
case "${GRUB_FS}" in
*fs) hurd_fs="${GRUB_FS}" ;;
*) hurd_fs="${GRUB_FS}fs" ;;
esac
for i in /hurd/${hurd_fs}.static /hurd/exec ; do
if test -e "$i" ; then
gettext_printf "Found Hurd module: %s" "$i" >&2
echo >&2
at_least_one=true
else
all_of_them=false
fi
done
if ${at_least_one} ; then : ; else
# no hurd here, aborting silently
exit 0
fi
if ${all_of_them} && test -e /lib/ld.so.1 ; then : ; else
gettext "Some Hurd stuff found, but not enough to boot." >&2
echo >&2
exit 1
fi
title_correction_code=
hurd_entry () {
kernel="$1"
type="$2"
kernel_base="`basename "${kernel}"`"
if [ x$type != xsimple ] ; then
if [ x$type = xrecovery ] ; then
title="$(gettext_printf "%s, with Hurd %s (%s)" "${OS}"
"${kernel_base}" "$(gettext "${GRUB_RECOVERY_TITLE}")")"
oldtitle="$OS using $kernel_base ($GRUB_RECOVERY_TITLE)"
else
title="$(gettext_printf "%s, with Hurd %s" "${OS}" "${kernel_base}")"
oldtitle="$OS using $kernel_base"
fi
if [ x"$oldtitle" = x"$GRUB_ACTUAL_DEFAULT" ]; then
quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
title_correction_code="${title_correction_code}if [ \"x\$default\" =
'$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
grub_warn "$(gettext_printf "Please don't use old title \`%s' for
GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or
later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title"
"gnuhurd-advanced-$boot_device_id>'gnuhurd-$kernel-$type-$(grub_get_device_id
"${GRUB_DEVICE_BOOT}")'")"
fi
sed "s/^/$submenu_indentation/" << EOF
menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option
'gnuhurd-$kernel-$type-$(grub_get_device_id "${GRUB_DEVICE_BOOT}")' {
EOF
else
sed "s/^/$submenu_indentation/" << EOF
menuentry '$(echo "$OS" | grub_quote)' ${CLASS} \$menuentry_id_option
'gnuhurd-simple-$(grub_get_device_id "${GRUB_DEVICE_BOOT}")' {
EOF
fi
prepare_grub_to_access_device "${GRUB_DEVICE_BOOT}" | grub_add_tab|sed
"s/^/$submenu_indentation/"
message="$(gettext_printf "Loading GNU Mach ...")"
if [ x$type = xrecovery ] ; then
opts="-s"
else
opts=
fi
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} $opts
${GRUB_CMDLINE_GNUMACH}
EOF
if [ x$type != xrecovery ] ; then
save_default_entry | grub_add_tab| sed "s/^/$submenu_indentation/"
fi
message="$(gettext_printf "Loading the Hurd ...")"
if [ x$type = xrecovery ] ; then
opts=
else
opts="--readonly"
fi
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
module /hurd/${hurd_fs}.static ${hurd_fs} $opts \\
--multiboot-command-line='\${kernel-command-line}' \\
--host-priv-port='\${host-port}' \\
--device-master-port='\${device-port}' \\
--exec-server-task='\${exec-task}' -T typed '\${root}' \\
'\$(task-create)' '\$(task-resume)'
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
}
EOF
}
title_correction_code=
submenu_indentation=""
is_top_level=true
while [ "x$kernels" != "x" ] ; do
kernel=`version_find_latest $kernels`
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy
]; then
hurd_entry "$kernel" simple
submenu_indentation="$grub_tab"
# TRANSLATORS: %s is replaced with an OS name
echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}"
| grub_quote)' \$menuentry_id_option
'gnuhurd-advanced-$(grub_get_device_id "${GRUB_DEVICE_BOOT}")' {"
is_top_level=false
fi
hurd_entry "$kernel" advanced
hurd_entry "$kernel" recovery
kernels=`echo $kernels | tr ' ' '\n' | fgrep -vx "$kernel" | tr '\n' ' '`
done
if [ x"$is_top_level" != xtrue ]; then
echo '}'
fi
echo "$title_correction_code"
-- no debconf information
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 725 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-grub-devel/attachments/20210213/e7bd4637/attachment.sig>
More information about the Pkg-grub-devel
mailing list