Re: Grub feature request?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mikkel L. Ellertson writes:
> Les Mikesell wrote:
> >=20
> > It would be even nicer if it could keep track of attempts and successes,
> > so that after a couple of attempts without success (i.e. an update
> > installed a new kernel as the default but it fails to boot), it could
> > drop back to an entry that had been successful previously.  That could
> > help in headless situations or where the machine is remote and the best
> > you can do is get someone else to punch the reset button.
> >
> Try the fallback option.
> 
> RTFM.

Unfortunately, TFM is less than clear about this stuff.
For example in the "Booting fallback systems" section
it discusses `grub-set-default' which does not seem to
exist.

That said, using what the manual says in that section, and a couple of
hours of futzing to corretly set the default back to stanza 0
when the system boots properly, here's what
I came up with couple of months back.
I think it does just what Les wants.

I've tested fairly well and it seems to work.

What the following does is boot my primary kernel (2.6.23.12-52.fc7)
(due to the "set default script" I'll discuss in a moment.  If that
fails, the 1st fallback ((2.6.23.8-34.fc7) will attempt to boot.  Both
of these are using the same filesystem, just a different
kernel/initrd.

Finally, if that fails, fallback 2 will attempt to boot my "alternate
system".  That's yet an older kernel and a bare-bones Fedora 7 system
that sits on a phyically separate disk than my main system.

###### relevant contents of my /boot/grub/grub.conf #####
default=saved
timeout=10
fallback 1 2

title Fedora (2.6.23.12-52.fc7)
	root (hd0,1)
	kernel /vmlinuz-2.6.23.12-52.fc7 ro root=/dev/vg01/lv00 vga=794
	initrd /initrd-2.6.23.12-52.fc7.img
        savedefault fallback

title Fedora (2.6.23.8-34.fc7)
	root (hd0,1)
	kernel /vmlinuz-2.6.23.8-34.fc7 ro root=/dev/vg01/lv00 vga=794
	initrd /initrd-2.6.23.8-34.fc7.img
        savedefault fallback

title alt_sys (2.6.22.9-91.fc7)
	root (hd0,1)
	kernel /vmlinuz-2.6.22.9-91.fc7 ro root=/dev/vg00/lv00 vga=794
	initrd /initrd_alt_sys-2.6.22.9-91.fc7.img
        savedefault
########################################################


Now, the problem with the above is that if the main system boots
successfully using stanza 0, the fallback will still be set to 1 which
means that the _next time_ I boot, stanza 1 gets used---not what I
want.  So I had to write a replacement for `grub-set-default'

I put this little script in my /boot/grub directory:

############# /boot/grub/resetDefaultBoot.sh ###########
#!/bin/sh

/sbin/grub --batch <<EOF 1>/dev/null 2>/dev/null
root (hd0,1)
savedefault --default=0
quit
EOF
#######################################################

Finally, to /etc/rc.d/rc.local I added the following
lines:

# Reset default boot to stanza 0 in /etc/grub/grub.conf
/boot/grub/resetDefaultBoot.sh

I've forced a failure of my main kernel, as well as the 2nd kernel
(stanza 1) and it correctly goes to my alternate system.  Note that
for _that_ system, I do not use the modified /ec/rc.d/rc.local file so
once it boots, it will keep booting the alternate system till I (by
hand) reset the default from the CLI.

Hope that helps.

Dean


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux