I have a dual Windows 7/Ubuntu system which I almost always boot into Windows. When I boot into Ubuntu it makes memtest the default boot menu option. Whilst this is annoying I could live with it if I were able to change the default back from the grub command line available from the boot menu. I don't want to have to boot into Ubuntu to fix this problem every time.

I am able to find the grub config file and can see the contents (sort of) by using:

cat (hd0,5)/boot/grub/grub.cfg

(although this only shows me the 'tail' not the whole file).

and the command:

configfile (hd0,5)/boot/grub/grub.cfg

executes this configuration (again).

Is it possible to edit this file from the grub command line?

The grub (1.99) manual suggests that I can use the Environment Block to:

set the default menu entry based on what was selected the last time

which may fix my problem but I can't find any examples of their use... Can I somehow use the save_env and load_env commands?

Note: I have grub version 1.98

link|improve this question

75% accept rate
feedback

2 Answers

up vote 4 down vote accepted
+50

No, there is no way to change the default boot menu from the grub command line. The easiest way to do this is by booting into Linux.

Next time you boot, look at the order of boot options. Let's say you want to make Windows the default boot option, note down the line it is on, i.e. the 4th or whatever.

Edit /etc/default/grub

Find the line -

GRUB_DEFAULT=0

Subtract 1 from the number you noted above, let's it was 4 and change the text to read

GRUB_DEFAULT=3


Run update-grub2 from the shell.

link|improve this answer
Can I do this from the grub command line (accessed from the boot screen)? How do I edit the file from there? – Matthew Murdoch Sep 27 '11 at 12:52
You can't make the changes I described without booting into linux. If you can't boot the installed system, you can use a live cd. – bryan Sep 28 '11 at 5:16
So the answer to my original question is 'No (it is not possible)'? – Matthew Murdoch Sep 28 '11 at 8:18
feedback

Using the Super Grub Disk is easier than using a live CD.

See this tutorial : GRUB 2 recovery.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.