How do I set the fallback entry by ID or select an entry in a submenu? The only option that works currently is using numbered entries (i.e. set fallback=0).


My team remotely updates devices running Debian. These units are deployed remotely, so physical or KVM access is infrequent and therefore not a viable solution. We copy the new system image onto an identical partition (/dev/sda2 in this case).

root@widget:~# lsblk
sda      8:0    1 186.3G  0 disk
├─sda1   8:1    1   953M  0 part /boot
├─sda2   8:2    1  23.3G  0 part /
├─sda3   8:3    1  23.3G  0 part /alt 

After remounting the /alt partition, we want to verify that the image is not corrupt. To test this, we make a custom entry (e.g. newimg in /etc/grub.d/40_custom). The UUID starting with xxxxxxxx is the partition mounted on /boot (dev/sda1) and the UUID starting with yyyyyyyy is the partition mounted on / (/dev/sda3).

menuentry 'Debian 10 (buster) newimg' --id newimg {
        insmod part_msdos
        insmod ext2
        search --no-floppy --fs-uuid --set=root xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
        linux /vmlinuz-4.2 root=UUID=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy ro nomodeset panic=5 quiet
        initrd /initrd.img-4.2
set fallback='1>2'

Next we run update-grub and grub-reboot newimg to perform a one time reboot. In the case that the image is corrupt, we need a fallback image so we don't lose access to the terminal. In the past we would use the first grub menu entry as the fallback (set fallback=0). However, the new /vmlinuz-4.2 will be used in the newest or 0 entry, so that would pointlessly fall back to itself. I have been testing fallback with the corrupt image vmlinuz-4.2. According to the GRUB documentation,

The entry may be identified by number (starting from 0 at each level of the hierarchy), by title, or by id.

However, the only valid method I've seen is using the numbers (I can't get submenu entries to work either). With every other option I get this error message: Failed to boot both default and fallback entries.

Things I've tried:

  • If I change the fallback in 40_custom to set fallback='1>2' (Advanced options for Debian GNU/Linux > Debian GNU/Linux, with Linux 4.1) it does select entry 1, but it does 1>0 instead of 1>2. And 1>0 selects the same corrupted vmlinuz image.
  • I also tried adding another custom boot entry that uses the old kernel (defaultimg) and changing the fallback to set fallback=defaultimg after verifying that I can successfully boot manually to defaultimg.
  • I tried changing both of the previous options without the set and with single quotes and double quotes.

GRUB version: 2.02+dfsg1-20


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.