Originally Posted by
mdlueck
I just tried that, same behavior. As if it is set to =0.
Since there is a bit of automagic partition detection with this new Grub, where does one look to see if savedefault is a behavior of a given menu choice?
The entry is stored in /boot/grub/grubenv, but it's not as simple as that.
Warning: Geek alert. You may not wish to read any further.
I played a bit with the "saved" setting when G2 first came out but haven't used it much since, and not with Windows.
After stumbling on this thread about three hours ago, I've been testing the "saved" entry.
The "saved" string is entered into /boot/grub/grubenv. If you change the default to "saved" and run update-grub, you won't see it immediately. The "saved" entry appears to be updated when a selection is made from the Grub 2 menu.
For Windows, I just entered "saved" as the DEFAULT in /etc/default/grub, ran "sudo update-grub" and booted to Windows. While in Windows, I checked the contents of /boot/grub/grubenv and indeed it contained the Windows title. When I rebooted, Windows was the highlighted entry.
Now a couple of interesting points. If you return to the G2 menu with Windows highlighted and change to Ubuntu, boot, and then check grubenv, it will now show "Ubuntu... " or whatever you just booted to. So the only way you would normally ever see the Windows entry in grubenv would be from within Windows (when Windows was the last booted entry).
Secondly, "saved" would be better labeled "lastused" IMO. It is saved only if no other selection is made. If you make another selection from the menu, that item now becomes the "saved" entry.
Another point: You can probably edit grub environment and place the title on the second line, EXACTLY as the string is depicted in grub.cfg (everything between the quotes), HOWEVER:: it appears grubenv must be exactly 1024 bytes. I've edited and saved it before and it generated an error message on boot saying it was an incorrect size. So if you edit it, it looks like it needs to be exactly 1024 bytes (add or subtract # symbols if not). Fortunately, there is a script to do this for you: grub-editenv run as root.
You can view the current contents with this command:
Code:
sudo grub-editenv /boot/grub/grubenv list
You can create a new, default grubenv file. For me, I have to delete the current /boot/grub/grubenv file before it will create the new one. This will also fix "environment" errors (if you delete the existing file first).
Code:
sudo grub-editenv /boot/grub/grubenv create
To create a new saved default without having to boot into it first:
Code:
sudo grub-editenv /boot/grub/grubenv set saved_entry="Exact_menuentry_from_grub.cfg"
sudo update-grub
One final bit of geekiness: In Grub legacy, the "saved" setting was saved as the DEFAULT number (0,1,2,etc). If a new kernel was added automatically, it became 0 and you would no longer get your old kernel, even if it was "saved". G2 stores the "saved" value as a string, so even after an update, the older kernel would still be the "saved" one, if though it's position in the menu had dropped down one entry.
Summary
Here is how it should work:
/etc/default/grub: DEFAULT=saved
sudo update-grub
Boot to Windows
Windows should be highlighted the next time you boot.
It should stay Windows until you select another OS.
Here is what I'd try if "saved" isn't working:
Remove /boot/grub/grubenv
Create a new grubenv (see above)
Add the exact Windows entry to grubenv using the grub-editenv set command (see above).
Update grub.
Reboot.
See if the Windows entry is highlighted.
If you always want to have Windows as the highlighted entry, use the Windows string in the DEFAULT setting of /etc/default/grub.
Example:
GRUB_DEFAULT="Microsoft Windows XP Home Edition (on /dev/sda1)"
Then update grub.
Bookmarks