For several releases, grub-installer sometimes could not find the right place to install the bootloader. See:
Bug 706112: debian-installer: Wheezy installer always install bootloader in /dev/sda
Related to a problem known since etch, see Bug 389881: SCSI device renaming breaks install
Objectives
- the easiest possible user experience: for a first-time user who has no clue which option to choose, we must give a sensible suggestion
- allow a more experienced user to override it, if he/she has special requirements for a more complex configuration
- support pre-seeding; allow it to be automatically guessed or set to something specific
History
Behaviour in wheezy
- initially assume "(hd0)"
- use grub-mkdevicemap in the /target chroot, to try to convert this to a device path (next two checks fail otherwise)
- if that succeeded, and $cdsrc is a partition on that disk (this didn't work - was fixed by commit below), use the device containing /boot instead
- if that failed, and if /cdrom looks like USB/hybrid media install, use the device containing /boot instead
- if /hd-media looks like USB/hybrid media, use the device containing /boot instead
- if we know the device path for "(hd0)", and it has no partition table or filesystem, use the device containing /boot instead
:TODO: what happens if existing bootloader / OSes are detected?
Behaviour in current daily d-i
the same complex logic as before http://sources.debian.net/src/grub-installer/1.96/grub-installer/?hl=641#L678
if (hd0) seems correct after the checks above, it will ask to install to "the MBR of the first disk" (this yes/no dialog doesn't give the user any information to help identify the disk)
otherwise, a new dialog asks the user to confirm http://sources.debian.net/src/grub-installer/1.96/grub-installer/?hl=641#L608
the first option is "Enter device manually", followed by $dev_list in grub-mkdevicemap order; each device listed in the dialog includes a description to help identify it
choosing "Enter device manually" gives a much less informative dialog asking for an exact device path
:FIXME: in the first dialog, $default_choice is supposed to preset the default selection to our best guess - is that not working properly?
in preseed installs, "Enter device manually" seems to be always chosen and the install gets stuck, see:
Bug 712907: grub-installer: No longer installs automatically on a normal machine with one hard drive
Dialogs
Install the GRUB boot loader to the master boot record? <Go Back> <Yes> <No>
This is not very good. It is sometimes wrong about which disk has the MBR. It doesn't give information to help the user identify the device before confirming. This dialog is only shown in some cases (typically CD/DVD/PXE installs).
Device for boot loader installation: [o] Enter device manually [ ] /dev/sda (ata-QEMU_HARDDISK_QM00001) <Go Back>
This dialog (new since wheezy) is much better. Sometimes(?) the default selection is something other than the "Enter device manually" option. All devices detected by grub-mkdevicemap are listed, along with some information to help identify them.
Device for boot loader installation: /dev/sda________ <Go Back> <Continue>
This is also not very good. Only an expert user should be asked something like this. No list of detected devices is shown. It is too late to return to partman and look at mount points.
Test cases
# |
version |
arch, platform/hardware |
install media |
install target |
other |
result |
references / who can test |
1 |
wheezy |
i386 on old Fujitsu Amilo laptop |
Xfce ISO booted from USB stick |
the first hard disk (of two) |
manual, whole-disk LVM |
asks to enter device manually, pre-filled with /dev/sdb (correct) but the instructions are to use /dev/sda for the first disk (which is wrong, that's the install media); detection is right but the user is given wrong instructions |
n/a - not my laptop |
2 |
jessie d-i daily 20140908 |
linux-i386 in Qemu |
PXE |
the only hard disk |
- |
grub-installer guesses (hd0), asks (yes/no) whether to install to MBR, it works |
anyone: qemu -hda hda.raw + TFTP options |
3 |
jessie d-i daily 20140911 |
kfreebsd-amd64 in Qemu |
PXE |
the only hard disk |
- |
grub-install does *not* assume (hd0), actually due to a bug, instead asks to choose from a list (other; /dev/ada0), but works if choosing /dev/ada0 |
|
4 |
jessie d-i daily |
amd64 in VirtualBox |
ISO image mounted as virtual CD-ROM |
the only hard disk |
auto preseed |
grub-install does *not* assume (hd0), but instead displays the new dialog of "Enter device manually" and only one more option (the only disk); this dialog interrupts the preseed process |
|
5 |
jessie d-i daily 20140914 |
kfreebsd-amd64 on BigV.io |
mini.iso as virtual CD-ROM |
the first hard disk (of two) |
expert mode; gpt, ZFS root, /boot on UFS |
asks (yes/no) whether to install to MBR, then asks to "Enter device manually" with no other options - grub-mkdevicemap doesn't understand recognise virtio device /dev/vtbd0 |
|
6 |
jessie d-i daily 20141001 |
linux-amd64 in Qemu |
mini.iso as (first) virtual hard drive |
one real hard disk |
- |
763580 pre-selects /dev/sda in list |
anyone: qemu -hda mini.iso -hdb foo.cow |
TODO: add examples of real hardware, which is where we have the most issues
When the detection is right
most CD/DVD installs? PXE installs?
When the detection is wrong
most(?) installs from a removable USB stick; the removable drive may appear as the first disk drive; the install media is broken if the bootloader is overwritten, and the system's real hard drive left without a bootloader
installs to an external hard drive (but is it possible to guess the user's intent in this situation?)
perhaps when firmware is loaded from USB stick - could be inserted before or after boot - could grub-mkdevicemap ever mistake it for (hd0)?
multipath? SATA RAID?