Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 {
    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?

share|improve this question
I suppose knowing where the grub log was could also accomplish this... – timh May 25 '12 at 23:59
up vote 1 down vote accepted

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.