On Wed, Mar 7, 2012 at 12:44 PM, Hongming Xiao <[email protected]> wrote: > All, > > The grub manual says: > > fallback > > If this variable is set, it identifies a menu entry that should be > selected if the default menu entry fails to boot. Entries are > identified in the same way as for ‘default’ (see default). > > My question is: how does grub know whether the system "fails to boot"? > Let's say in grub.conf default is set to 0 and fallback is set to 1,
Just to be clear, this list is for grub2 which uses grub.cfg, not grub.conf (used by some forks of grub legacy). > will system boot into 1 in following scenarioes? If yes, from where > grub learn what happened? > > a) kernel 0 crashed during startup no > b) kernel 0 failed to start some service during startup? no > c) kernel 0 crashed at any time no > d) cycling power while kernel 0 startup? no Only if the commands in the menu entry fail. For instance, if the vmlinuz file cannot be read by grub and so the "linux" command fails. More *could* be done to change to a fallback entry the next boot after booting fails after grub has passed control to the kernel. Ubuntu for instance has grub set a variable recordfail (which is stored in /boot/grub/grubenv using the save_env command) and then has a service at boot, /etc/init.d/grub-common, which clears this variable indicating that booting was successful (successful in this case meaning that booting got as far as the grub-common service being "started"). If at boot the recordfail flag is still there, then something failed between grub and /etc/init.d/grub-common and Ubuntu unhides the menu and removes the timeout so that the user has an opportunity to see the menu and change options themselves (Ubuntu normally hides the menu by default). With grub's scripting capabilities this could easily be changed to 'if [ "$recordfail" = 1 ]; then default=foo; fi' if you wanted to set something like this up yourself. > .... > > Thanks, > Huang Zhong > > _______________________________________________ > Help-grub mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/help-grub -- Jordan Uggla (Jordan_U on irc.freenode.net) _______________________________________________ Help-grub mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-grub
