Making "default saved" work with GRUB2...?

8

3

I just installed Moblin Operating System. It's using GRUB2. On my Ubuntu 8.04 GRUB 0.97 was being used in which i was using the default saved option comfortably. I found that with GRUB2 i should not edit /boot/grub/menu.lst directly but I did :) because my Moblin does not contain any /etc/default/grub where they say I should do the modification I want.

So what I did is as following which did not work:

default=saved
timeout=1
#splashimage=(hd0,0)/boot/grub/splash.xpm.gz
#hiddenmenu
#silent
title Moblin (2.6.31.5-10.1.moblin2-netbook)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.31.5-10.1.moblin2-netbook ro root=/dev/sda1 vga=current
        savedefault=1

title Pathetic Windows
        rootnoverify (hd0,1)
        chainloader +1
        savedefault=0

By doing so I should have automatically switch between Moblin and Window at each boot but it's not working.

Almost all the troubleshooters on internet are saying that I should enable the DEFAULT=save option in /etc/default/grub but I am unable to find this file. Any idea what else should I do?

Thanks a lot

Update:

I used the equal to sign because by default my menu.lst had an entry as default=0. However, default 0, is also working fine.

Moreover the menu.lst, i have is actually a symbolic link to ./grub.conf. I have also noticed that grub-intall and grub-set-default commands are not working.

Usman

Posted 2010-01-14T11:09:06.120

Reputation: 757

if you have a working /boot/grub/menu.lst you are not using Grub2. Grub2 uses /boot/grub/grub.cfg. you may see both configuration files if you've updated to Grub2 from an older installation that used Grub1. – quack quixote – 2010-02-10T15:45:16.123

You're using 0-based numbering for disk partitions -- that doesn't look like GRUB2, that looks like Legacy GRUB. – ephemient – 2010-01-14T15:34:48.683

Answers

19

The correct syntax for enabling savedefault in /etc/default/grub (GRUB 2) is with the lines:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

and not with the line DEFAULT=save that the enquirer suggested.

After adding the two lines above to /etc/default/grub, one has to update GRUB's configuration, as a superuser, with the following commands:

grub-mkconfig
update-grub

At least on Lubuntu 12.10, grub-mkconfig is not needed (as it, without options, dumps the config file to stdout). The only needed command is update-grub which actually invokes grub-mkconfig with the proper -o file option.

edin1

Posted 2010-01-14T11:09:06.120

Reputation: 308

One detail is that at least on Ubuntu, the memtest entries won't be saved incase you decide to try them to test the feature quickly... – Pricey – 2018-01-15T20:21:40.343

1

I'm not sure if GRUB allows the = sign; my configuration reads default saved.

Your problem is that the Pathetic Windows entry does not do a savedefault, so the default entry is never changed to Windows.

Edit: Furthermore, savedefault by default saves the current entry; only if you give it a number will it save another entry than the current one.

Try this:

default saved
timeout 1
#splashimage (hd0,0)/boot/grub/splash.xpm.gz
#hiddenmenu
#silent
title Moblin (2.6.31.5-10.1.moblin2-netbook)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.31.5-10.1.moblin2-netbook ro root=/dev/sda1 vga=current
        savedefault

title Pathetic Windows
        rootnoverify (hd0,1)
        chainloader +1
        savedefault

I don't know Moblin but in other distributions it is common to have the configuration file somewhere in /boot/grub, not in /etc.

Thomas

Posted 2010-01-14T11:09:06.120

Reputation: 4 979

+1 cuz it worked for me (though the OP did ask about grub2) – nhed – 2013-04-17T17:08:47.477

I would put the savedefault command first, as it is unclear to me wether chainloader or kernel calls exit the boot loader immediately.. – None – 2010-01-14T12:42:26.050

I use the equal to sign because by default my menu.lst had an entry as default=0. However, default 0, is also working fine. Moreover the menu.lst i have is actually a symbolic link to ./grub.conf

I have also checked that grub-intall and grub-set-default commands are not working. – None – 2010-01-14T14:23:49.080

See also my edit. You shouldn't give savedefault a number. – None – 2010-01-14T15:33:43.370

the syntax is savedefault N not savedefault=N (again, if you want it to save another entry as the default -- if you want current entry, leave N off). – quack quixote – 2010-01-14T17:58:55.023