PDA

View Full Version : [all variants] GRUB2: set default=saved does not work for me



dubbaluga
November 8th, 2009, 04:46 PM
Hi,

I was upgrading to GRUB2 recently. Since then I configured this awesome piece of software to save the last working configuration for the booting choice using the following stanza in /boot/grub/grub.cfg:

set default=saved
Does anyone of you know what I have to do else than that? I am remembering the times of GRUB which used a file called /boot/grub/default which could be modified using the grub-set-default command. Is there something similar in GRUB2? I could not find it in the documentation.
Thx and regards, Rainer

oldfred
November 8th, 2009, 04:57 PM
With grub2 you do not edit grub.cfg, it is rebuilt on every change or your rebuild it by running either the 'sudo update-grub' or 'sudo grub-mkconfig' command.

Eidit /etc/default/grub and run the update to rewrite grub.cfg.

https://help.ubuntu.com/community/Grub2

dubbaluga
November 8th, 2009, 05:17 PM
Thanks for your answer,
I already thought to mention that I actually added an entry in the /etc/default/grub file which results in modifications of /boot/grub/grub.cfg after updating the configuration using the grub2-utils with tools like those mentioned by you above:

GRUB_DEFAULT=saved
Regarding the problem I really have, I thought it to be sufficient to tell you that these modifications already have gone into the main configuration grub.cfg which is parsed by GRUB2 upon startup.

Well, is it necessary to do something else than taking care that all configuration is at its proper place?

oldfred
November 8th, 2009, 10:36 PM
I guess I am not sure what is your problem. Does it not reboot with the last (saved) entry?

More info on grub2
http://ubuntuforums.org/showthread.php?t=1195275
https://wiki.ubuntu.com/Grub2#Adding%20Entries%20to%20Grub%202
http://ubuntuforums.org/showthread.php?p=8191211#post8191211
http://members.iinet.net/~herman546/p20/GRUB2%20Configuration%20File%20Commands.html

And those sites have links to others with what info is available. Grub2 is still a beta and a work in progress.

dubbaluga
November 8th, 2009, 10:54 PM
Yep, that's exactly it - it does not boot with the last entry. Sorry for not mentioning that clearly enough.

oldfred
November 8th, 2009, 11:48 PM
It should be:
GRUB_DEFAULT=saved

If that is not working post a copy of you grub and your grub.cfg, maybe a typo that someone will see? Otherwise I do not know.

dubbaluga
November 9th, 2009, 09:27 AM
To be honest, I am using Debian GNU/Linux, but that should not matter. Here is my configuration of GRUB2. It's generated using update-grub2, which in turn uses grub-mkconfig. As you might see, I am using xfs on almost all of my partitions:



#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set default=saved
insmod xfs
set root=(hd0,8)
search --no-floppy --fs-uuid --set d2d73fc6-a857-4c9d-a037-8d6328107d1e
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
set timeout=5
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
insmod xfs
set root=(hd0,8)
search --no-floppy --fs-uuid --set d2d73fc6-a857-4c9d-a037-8d6328107d1e
insmod tga
if background_image /usr/share/images/grub/berlin_ccc.tga ; then
set color_normal=black/black
set color_highlight=magenta/black
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Debian GNU/Linux, Linux 2.6.31-14-generic" {
insmod xfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set 78547c14-277f-4468-b1fe-7fcca4938c60
linux /vmlinuz-2.6.31-14-generic root=UUID=d2d73fc6-a857-4c9d-a037-8d6328107d1e ro
initrd /initrd.img-2.6.31-14-generic
}
menuentry "Debian GNU/Linux, Linux 2.6.31-14-generic (recovery mode)" {
insmod xfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set 78547c14-277f-4468-b1fe-7fcca4938c60
linux /vmlinuz-2.6.31-14-generic root=UUID=d2d73fc6-a857-4c9d-a037-8d6328107d1e ro single
initrd /initrd.img-2.6.31-14-generic
}
menuentry "Debian GNU/Linux, Linux 2.6.30-2-amd64" {
insmod xfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set 78547c14-277f-4468-b1fe-7fcca4938c60
linux /vmlinuz-2.6.30-2-amd64 root=UUID=d2d73fc6-a857-4c9d-a037-8d6328107d1e ro
initrd /initrd.img-2.6.30-2-amd64
}
menuentry "Debian GNU/Linux, Linux 2.6.30-2-amd64 (recovery mode)" {
insmod xfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set 78547c14-277f-4468-b1fe-7fcca4938c60
linux /vmlinuz-2.6.30-2-amd64 root=UUID=d2d73fc6-a857-4c9d-a037-8d6328107d1e ro single
initrd /initrd.img-2.6.30-2-amd64
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

Thx for reading!

oldfred
November 9th, 2009, 04:07 PM
You have:
set default=saved
The command is :
GRUB_DEFAULT=saved

But are you running the same version of grub?
versions?
grub-install -v

EnfieldUK
November 26th, 2009, 02:13 PM
You have:
set default=saved
The command is :
GRUB_DEFAULT=saved

But are you running the same version of grub?
versions?
grub-install -v

I have the same problem too; am using GNU GRUB 1.97~beta4

The file posted above by the OP appears to be /boot/grub/grub.cfg which doesn't have the GRUB_DEFAULT=saved part in it.

wmrojer
November 26th, 2009, 08:37 PM
Is saving default even supported yet in grub2? On the grub wiki it is listen on the todoList.

http://grub.enbug.org/TodoList

PeggySue
November 27th, 2009, 12:07 PM
I had this problem as well. Here is my fix.
In /etc/grub.d/00_header I have this code:

#User set default from 0 to 2 and commented out saved option
if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=2 ; fi
#if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
#User added next line
GRUB_DEFAULT=2

Note that just changing 0 to 2 in the second line didn't work. I had to override the dodgy looking string tests with the last line (GRUB_DEFAULT=2). This works.

Don't forget sudo update-grub2 and then /boot/grub/grub.cfg looks like this:

### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
have_grubenv=true
load_env
fi
set default="2"


Hope this helps.

dieter.
February 6th, 2010, 01:40 PM
I had the same problem. Grub didn't find the environment file.
Reason: When you have a separate boot partition you need to "add" path /boot
with the following commands. Then file /boot/grub/grubenv will be found and it works.


cd /boot
mkdir boot
cd /boot/boot
ln -s ../grub grubAlternative: change line in /etc/grub.d/00_header


old: if [ -s /boot/grub/grubenv ]; then
new: if [ -s /grub/grubenv ]; then

Endolith
March 27th, 2010, 08:39 PM
I had the same problem. Grub didn't find the environment file.
Reason: When you have a separate boot partition you need to "add" path /boot
with the following commands. Then file /boot/grub/grubenv will be found and it works.


cd /boot
mkdir boot
cd /boot/boot
ln -s ../grub grubAlternative: change line in /etc/grub.d/00_header


old: if [ -s /boot/grub/grubenv ]; then
new: if [ -s /grub/grubenv ]; then

Why is this necessary? Shouldn't the path be correct if the boot partition is configured correctly?

indulis
April 18th, 2010, 04:52 AM
Why is this necessary? Shouldn't the path be correct if the boot partition is configured correctly?

No! I had to work this out too. If you have a separate boot partition sda1 that when the system is booted to Ubuntu is mounted at /boot, then say there is a file in that filesystem called my_file.

When the system is booted fully to Ubuntu, you will find the file at /boot/my_file.

Before you have booted Ubuntu, and are in Grub, partition sda1 is mounted at / (root). So the file appears at /my_file, NOT at /boot/my_file (cos there is nothing "mounted onto" /boot at this time).

I've given up on separate boot partitions and now use a separate small ext3 / partition instead- saves all the mucking about with changing paths before/after boot.

Pramod_rt
October 17th, 2010, 08:25 AM
Here is the answer:
Check out this link: http://ubuntuforums.org/showthread.php?t=1195275
Set GRUB_DEFAULT=saved and add a line GRUB_SAVEDEFAULT=true

Pramod