Wandering Thoughts archives

2007-12-13

Doing one-shot booting with GRUB

For a long time, one of the advantages of LILO over GRUB was that LILO had a one-shot mode, where it would make an entry the default for only one reboot. I've been pleased to recently discover that GRUB can now do this too, although in the grand Linux tradition it's not too documented.

The magic incantation is the GRUB shell command:

savedefault --default=<num> --once

(This has to be issued in a GRUB shell, such as what you get by just running grub. On my workstation I find the --no-floppy command line argument useful, but I may be one of the few people who still has a floppy drive in their machine.)

If you are using Red Hat's version of GRUB (found in Red Hat Enterprise and Fedora), this is all you need to do. On Ubuntu or anywhere else that uses the normal version of GRUB, you need to modify your grub.conf or menu.lst to have 'default = saved', and then add 'savedefault' (without a number) to every menu entry, or at least every menu entry that you will ever try to use in one-shot mode.

(I believe that you can tell which version of GRUB you have by whether or not you have a /boot/grub/default file and a grub-set-default command.)

The normal GRUB saves this in /boot/grub/default, which is a plain text file; a one-time entry shows up as N:O, where N is your normal default and O is the entry you'll boot once. Red Hat's GRUB directly embeds the information in the stage2 binary, and I don't know how you can see the current state.

(Judging from the changelog of the Fedora GRUB RPM, this may have been in their version of GRUB for a very long time. Unfortunately it has been undocumented for that very long time, or I might have felt slightly differently about GRUB back then.)

linux/OneShotGrub written at 23:35:19; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.