Doing one-shot booting with GRUB

December 13, 2007

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.)


Written on 13 December 2007.
« A more abstract view of the generalized open() issue
Check then use is a dangerous security pattern »

These are my WanderingThoughts
(About the blog)

Full index of entries
Recent comments

This is part of CSpace, and is written by ChrisSiebenmann.
Twitter: @thatcks

* * *

Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web

This is a DWiki.
GettingAround
(Help)

Search:

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Thu Dec 13 23:35:19 2007
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.