1

I am working on a remote server with no KVM, and am modifying stuff in the boot loader menu. I enabled the fallback and "default boot once" options in case for when I screw something up.

Is there a way to know (after boot) which menu entry in the GRUB2 item list was eventually chosen? That way I will know if a fallback occurred (ie. the "default once" failed).

I have entries like this in my /etc/grub/grub.cfg:

menuentry 'Ubuntu, with Linux 2.6.32-28-generic-pae TEST' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd0,1)'
    search --no-floppy --fs-uuid --set f70c6784-490f-4737-8168-cbcce4793b2b
    linux   /vmlinuz-2.6.32-28-generic-pae root=/dev/sda3 ro   panic=5
    initrd  /initrd.img-2.6.32-28-generic-pae
}

Is there a way I can set some type of environment variable in there, so that I can check after boot which entry was loaded? Or perhaps GRUB2 already has some way of knowing this?

1
  • I suppose knowing where the grub log was could also accomplish this...
    – timh
    Commented May 25, 2012 at 23:59

1 Answer 1

1

Anything you put on the linux line will be available via /proc/cmdline, so you could put a unique identifier there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .