Discussion:
Bug#1058638: grub-installer: boot fails: $bootdev empty [BIOS/MBR, Vista, 2 disks]: Installing grub on ''
(too old to reply)
Tj
2023-12-13 20:00:01 UTC
Permalink
Source: grub-installer
Version: 1.194
Severity: important
Tags: d-i

Whilst helping user "mavaviij" in matrix Debian room I was able to
reproduce in a virtual machine a bug that causes the Debian install to
fail to boot with a blinking cursor after install.

After a lot of code-chasing it appears the problem is that
grub-installer script fails to set its $bootdev variable:

grub-installer: info: Installing grub on ''

(note the empty quotes)

The target system has two 'disks'. The first has Microsoft Windows Vista
with 2 NTFS partitions using msdos label/MBR. The second is empty and intended
for the Debian OS and boot-loader.

The system boots in BIOS/Legacy/CSM mode.

I've not been able to trace back through the code to figure out why the
failure occurs. I have however identifed what may be a clue: the Debian
OS disk sector 0 appears to contain GRUB's g2hdr.img which makes me
wonder if grub-ntldr-img was used - although not sure how that is done
and see no sign of it in the (saved) installer logs.

Reproducer:

Using debian-12.4.0-amd64-netinst.iso

fallocate -l 1000000000 disk1-windows-vista.bin
fallocate -l 2000000000 disk2-debian-12.bin
fdisk disk1-windows-vista.bin
#new: 1, default,512M
#type: 1, 07
#new: 2, default, default
#type: 2, 07
#write

sudo losetup -P --show -f disk1-windows-vista.bin
# /dev/loop0
sudo mount /dev/loop0p1 /mnt/tmp/
# fool os-prober into detecting Vista
sudo mkdir /mnt/tmp/boot
sudo touch /mnt/tmp/bootmgr
echo "W i n d o w s V i s t a " | sudo dd of=/mnt/tmp/boot/bcd

find /mnt/tmp/ -ls; hexdump -C /mnt/tmp/boot/bcd
5 4 drwxrwxrwx 1 root root 4096 Dec 13 14:41 /mnt/tmp/
64 0 drwxrwxrwx 1 root root 0 Dec 13 14:42 /mnt/tmp/boot
65 1 -rwxrwxrwx 1 root root 27 Dec 13 14:32 /mnt/tmp/boot/bcd
67 0 -rwxrwxrwx 1 root root 0 Dec 13 14:41 /mnt/tmp/bootmgr
00000000 57 20 69 20 6e 20 64 20 6f 20 77 20 73 20 20 20 |W i n d o w s |
00000010 56 20 69 20 73 20 74 20 61 20 0a |V i s t a .|
0000001b

sudo umount /mnt/tmp
sudo os-prober
/dev/loop0p1:Windows Vista:Windows:chain

Now create a (libvirt/QEMU) VM guest with the 2 disk images attached and
go through the install procedure choosing the unpartitioned second disk
as the target.
At the question about installing the boot loader to the "primary disk"
answer No, then when the option to select which boot device to use choose
the 2nd disk where Debian is installed.

Save debug logs, restart VM, and even if using the SeaBIOS boot menu via
pressing Esc key, choosing the VirtIO boot device results in blinking
cursor.

Examine disk images and note that disk2 appears to have GRUB's g2hdr.img
in sector 0.

hexdump -C -n 512 disk2-debian-12.bin
00000000 fa b8 00 10 8e d0 bc 00 b0 b8 00 00 8e d8 8e c0 |................|
00000010 fb be 00 7c bf 00 06 b9 00 02 f3 a4 ea 21 06 00 |...|.........!..|
00000020 00 be be 07 38 04 75 0b 83 c6 10 81 fe fe 07 75 |....8.u........u|
00000030 f3 eb 16 b4 02 b0 01 bb 00 7c b2 80 8a 74 01 8b |.........|...t..|
00000040 4c 02 cd 13 ea 00 7c 00 00 eb fe 00 00 00 00 00 |L.....|.........|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001b0 00 00 00 00 00 00 00 00 13 43 3c 32 00 00 00 04 |.........C<2....|
000001c0 01 04 83 fe c2 ff 00 08 00 00 00 90 3b 00 00 00 |............;...|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00000200


NOTE: on an UEFI system doing the reproducer one needs to edit

/usr/lib/os-probes/mounted/20microsoft

and comment out the test for UEFI on lines 11-14 if wanting to manually
test os-prober outside the running installer.
Pascal-liste
2023-12-13 20:10:02 UTC
Permalink
Hello,
Post by Tj
After a lot of code-chasing it appears the problem is that
grub-installer: info: Installing grub on ''
(note the empty quotes)
The target system has two 'disks'. The first has Microsoft Windows Vista
with 2 NTFS partitions using msdos label/MBR. The second is empty and intended
for the Debian OS and boot-loader.
The system boots in BIOS/Legacy/CSM mode.
I suspect this is yet another avatar of bug #1035096, for which I
submitted a patch, see
<https://salsa.debian.org/installer-team/grub-installer/-/merge_requests/17>.
Tj
2023-12-13 21:40:01 UTC
Permalink
Source: grub-installer
Version: 1.194
Followup-For: Bug #1058638

I think this may be due to the same cause as #1035096 and possibly also
#1035085
Tj
2023-12-13 23:30:01 UTC
Permalink
Source: grub-installer
Version: 1.194
Followup-For: Bug #1058638

I fetched the proposed patch and applied it to grub-installer inside the
installer and can confirm it solved this issue.

syslog now shows "grub-installer: info: Installing grub on '/dev/vdb'
and examining sector 0 of the disk image file shows the expected
boot-strap code and a reboot correctly starts Debian:

hexdump -n 512 -C disk2-debian-12.bin
00000000 eb 63 90 10 8e d0 bc 00 b0 b8 00 00 8e d8 8e c0 |.c..............|
00000010 fb be 00 7c bf 00 06 b9 00 02 f3 a4 ea 21 06 00 |...|.........!..|
00000020 00 be be 07 38 04 75 0b 83 c6 10 81 fe fe 07 75 |....8.u........u|
00000030 f3 eb 16 b4 02 b0 01 bb 00 7c b2 80 8a 74 01 8b |.........|...t..|
00000040 4c 02 cd 13 ea 00 7c 00 00 eb fe 00 00 00 00 00 |L.....|.........|
00000050 00 00 00 00 00 00 00 00 00 00 00 80 01 00 00 00 |................|
00000060 00 00 00 00 ff fa 90 90 f6 c2 80 74 05 f6 c2 70 |...........t...p|
00000070 74 02 b2 80 ea 79 7c 00 00 31 c0 8e d8 8e d0 bc |t....y|..1......|
00000080 00 20 fb a0 64 7c 3c ff 74 02 88 c2 52 be 80 7d |. ..d|<.t...R..}|
00000090 e8 17 01 be 05 7c b4 41 bb aa 55 cd 13 5a 52 72 |.....|.A..U..ZRr|
000000a0 3d 81 fb 55 aa 75 37 83 e1 01 74 32 31 c0 89 44 |=..U.u7...t21..D|
000000b0 04 40 88 44 ff 89 44 02 c7 04 10 00 66 8b 1e 5c |***@.D..D.....f..\|
000000c0 7c 66 89 5c 08 66 8b 1e 60 7c 66 89 5c 0c c7 44 ||f.\.f..`|f.\..D|
000000d0 06 00 70 b4 42 cd 13 72 05 bb 00 70 eb 76 b4 08 |..p.B..r...p.v..|
000000e0 cd 13 73 0d 5a 84 d2 0f 83 d8 00 be 8b 7d e9 82 |..s.Z........}..|
000000f0 00 66 0f b6 c6 88 64 ff 40 66 89 44 04 0f b6 d1 |***@f.D....|
00000100 c1 e2 02 88 e8 88 f4 40 89 44 08 0f b6 c2 c0 e8 |***@.D......|
00000110 02 66 89 04 66 a1 60 7c 66 09 c0 75 4e 66 a1 5c |.f..f.`|f..uNf.\|
00000120 7c 66 31 d2 66 f7 34 88 d1 31 d2 66 f7 74 04 3b ||f1.f.4..1.f.t.;|
00000130 44 08 7d 37 fe c1 88 c5 30 c0 c1 e8 02 08 c1 88 |D.}7....0.......|
00000140 d0 5a 88 c6 bb 00 70 8e c3 31 db b8 01 02 cd 13 |.Z....p..1......|
00000150 72 1e 8c c3 60 1e b9 00 01 8e db 31 f6 bf 00 80 |r...`......1....|
00000160 8e c6 fc f3 a5 1f 61 ff 26 5a 7c be 86 7d eb 03 |......a.&Z|..}..|
00000170 be 95 7d e8 34 00 be 9a 7d e8 2e 00 cd 18 eb fe |..}.4...}.......|
00000180 47 52 55 42 20 00 47 65 6f 6d 00 48 61 72 64 20 |GRUB .Geom.Hard |
00000190 44 69 73 6b 00 52 65 61 64 00 20 45 72 72 6f 72 |Disk.Read. Error|
000001a0 0d 0a 00 bb 01 00 b4 0e cd 10 ac 3c 00 75 f4 c3 |...........<.u..|
000001b0 00 00 00 00 00 00 00 00 13 43 3c 32 00 00 80 04 |.........C<2....|
000001c0 01 04 83 fe c2 ff 00 08 00 00 00 90 3b 00 00 00 |............;...|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00000200
Debian Bug Tracking System
2025-01-17 22:50:02 UTC
Permalink
Your message dated Fri, 17 Jan 2025 22:34:52 +0000
with message-id <E1tYuvU-002hYk-***@fasolo.debian.org>
and subject line Bug#1058638: fixed in grub-installer 1.207
has caused the Debian Bug report #1058638,
regarding grub-installer: boot fails: $bootdev empty [BIOS/MBR, Vista, 2 disks]: Installing grub on ''
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ***@bugs.debian.org
immediately.)
--
1058638: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1058638
Debian Bug Tracking System
Contact ***@bugs.debian.org with problems
Loading...