[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1058638: grub-installer: boot fails: $bootdev empty [BIOS/MBR, Vista, 2 disks]: Installing grub on ''



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.


Reply to: