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

Re: Booting once on a different OS (with grub)



On Fri 22 Jun 2018 at 14:07:58 (+0000), davidson wrote:
> On Fri, 22 Jun 2018, Pétùr wrote:
> 
> >Is there a way to tell grub to boot the next time (and only this time)
> >to a different OS than the default one?
> 
>    $ man -k reboot
>    grub-reboot (8) - set the default boot entry for GRUB, for the next
>    boot only
>    [snip]
> 
> Caveat: I have never used it.

Yes, I use this to do filesystem checks.

I did these one-off operations:

# nano /etc/default/grub
GRUB_DEFAULT=0 → GRUB_DEFAULT=saved

and

# grub-set-default 0
# grub-mkconfig > /boot/grub/grub.cfg

which sets up /boot/grub/grubenv for normal booting.

Then using the command

# grub-reboot 'foo>bar'

will prime grub to boot the entry in /boot/grub/grub.cfg that looks like:

submenu 'Mumble' $menuentry_id_option 'foo' {
	menuentry 'Rhubarb' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'bar' {

where foo and bar are typically very long strings. Note that it
*primes* it to reboot foo/bar: you don't have to reboot straight away;
you could close down in the normal way at the end of the day and
switch on in the morning.

For fsck, I duplicate the top entry in the submenu, put fsck and fsck
in place of foo and bar, and add   forcefsck   to the linux line.
This ensures the root filesystem gets checked. Then closing down with

# grub-reboot 'fsck>fsck'
# /sbin/shutdown -P now

will make my server do the file check when it automatically wakes up
early the next morning.

I assume Debian doesn't write such an entry by default (like they do
for single) because checking filesystems is no longer considered necessary.

Cheers,
David.


Reply to: