grubby details of grub2

Rashkae ubuntu at tigershaunt.com
Sun Oct 3 21:56:56 UTC 2010


On 10-10-03 05:12 PM, Kevin O'Gorman wrote:
> I'm running Lucid on my laptop, and have been transported into the 
> grub2 reality.  At least I think so because
> of the huge changes in /boot/grub/.  I no longer understand much of it.
>
> Somewhat to my amazement I got it working.  I even dual boot to 
> Vista.  Problem is that I want to change
> where that Vista entry appears in the menu, and I have NO clue.  I 
> heard that menu.lst no longer exists,
> and that configuration now goes in grub.cfg.  Then I notice the 
> warning not to touch that file because it's
> automatically generated.  I find myself unable to sort out the layers 
> of the new setup.
>
> Since all I ordinarily use is the first Linux entry and the Vista 
> entry, I'd like to move Vista up to the top or second
> spot.  That's it.  I figure it might take me a day to figure this 
> out, but free days are hard to come by and I'm
> hoping somebody can give me a short recipe.
>
There are, unfortunately, no short recipes.

But I will start off by letting you know this.  There is no need to fear 
the warning about not editing grub.cfg.  Nothing particularly bad will 
happen to you if you do.  The only thing you need to be aware of is that 
the file is auto-generated, and will be regenerated whenever the package 
manager feels like (ex: when a kernel is updated, or even when you want 
to make a change to grub and run grub-update.).  So that makes it a bad 
place to make changes that your system needs to boot reliably (ie, 
custom kernel parameters, for example.).  If, however, the prospect of 
the menu returning to it's default state with little or no warning 
doesn't frighten you, then by all means, hack grub.cfg to your liking.

As you probably already know, the grub.cfg file is generated by the 
scripts in the /etc/grub.d directory.

Those scripts are executed in alphabetical order (hence why they are 
numbered,) so one easy change you can make is:

mv 30_os-prober 15_os-prober

os-prober is the script that finds and adds Windows to the grub menu, so 
by making it run before memtest, then memtest, at least will be below 
windows in the grub menu.

You might also want to suppress the linux rescue mode entries.  You can 
specify that in the /etc/default/grub file.  Remove the # to uncomment 
"GRUB_DISABLE_LINUX_RECOVERY="true" ".

After that, use your favorite package manager to remove any older kernel 
images you have.

If these steps do not make the menu look the way you like, then the next 
step is to craft your own menu entries.  That's what the 
/etc/grub.d/40_custom file is for.  Copy the sections you want from 
grub.cfg file, and paste them into 40_custom.  Then, you give those 
custom entries top billing with:

mv 40_custom 09_custom (which will make it run before the automatically 
generated entries)

There is one important caveat to that last method which makes it the 
least advised.  You will have to manually make any updates to the custom 
entries.  If you boot from one of those entries, you will not 
automatically benefit from kernel updates that come as part of your 
regular system update process.






More information about the ubuntu-users mailing list