CQuirke’s Long View

Long lead times need long forward planning

Edit grub Menu In Ubuntu 9.10 and Older

Posted by cquirke on 20 November 2009

Technorati tags: , ,

Windows users who install Ubuntu as a dual boot installation to try it out, will usually want their PCs to boot into Windows by default.  Ubuntu makes this possible, but not easy; it’s a major “paper cut” to address.

Ubuntu 9.04 and older

Before Ubuntu 9.10, you would start a Terminal session and do this:

cd /boot/grub
sudo chmod 666 menu.lst
gedit menu.lst
sudo chmod 644 menu.lst

You can set an explicit default boot entry, but I prefer to leave grub to boot the first entry as it does by default, but make that first entry the one I want.

So, when editing the menu.lst file, I usually cut the entry at the end of the file that launches Windows, and paste it into the top of the section that defines the boot menu entries.  I then rename the displayed text from something horrible like “Microsoft Operating System” to what I want, e.g. “Windows 7 Pro 64”.  Then I page down and delete the redundant do-nothing “Other Operating Systems” entry at the end.

Ubuntu 9.10 with grub 2

Ubuntu 9.10 uses a newer version of grub that works differently; do this:

cd /etc/default
sudo chmod 666 grub
gedit grub
sudo chmod 644 grub
sudo update-grub

You can’t edit the menu text that will be displayed in the boot menu anymore, because the new grub version doesn’t use your setting file directly.  Instead, it builds a new internal “don’t edit this” settings file that combines your settings with what it detects – and the menu entry text is built from what it detects, not your settings.  The update-grub command is needed to force a new build of the internal settings file.

When I edit the grub file, I don’t try to specify which boot menu entry to use by default, nor re-arrange the order of these entries with my choice at the top.  Because update-grub spawns a new menu that may differ from what is in effect as I edit the grub file, the first approach could misfire, and the second approach won’t work.

Instead, I use a new “saved” value for the “default” setting, which has the happy effect of defaulting to whatever the user chose last time.

But by default, the grub boot menu is not displayed, so I change entry to force it to be displayed, and set the timeout value after which the default kicks in:

GRUB_DEFAULT=saved
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT="20"

Alert!

If you dual-boot Ubuntu (or similar, using grub) and Windows, have multiple Windows-visible partitions, and use WAIK or OPK imaging tools (WinPE, ImageX) then there’s a serious bum-biting trap waiting for you – not so much a bug, as a natural consequence of how grub works.

Advertisements

4 Responses to “Edit grub Menu In Ubuntu 9.10 and Older”

  1. cosmin said

    So in conclusion, grub developers did a great improvement. You can’t edit anymore the options text, the order, or even the default options. This kind of developers should try to find another job.

  2. jack said

    why have they made a boot loader so complicated? LILO used to be a piece of cake. Seriously. It just needs to boot a partition.

  3. Chris Quirke said

    Yep, I think it sucks, too. Linux usually prides itself on no closed binary settings files, everything’s editabl;e text, but the new grub breaks this trend.

    There’s also a typical “piggy vendor” unwillingness to enable folks to do what they are likely to want to do, and this applies to Firefox (defaults to “set as default browser”, doesn’t reflect your current choice of default browser) as well as Ubuntu. It’s the usual arrogant-vendor “why would anyone not want to use out software for everything?” mindest.

    I’d rather see the Umbuntu installer detect the presence of other OSs, and UI an easy choice of which OS you want to boot by default (or “last booted”), how long a time-out period, etc. IOW, provide a proper UI for grub setup and chain the installation process into that UI.

  4. ander said

    Wow. This is a perfect example of the kind of thing that scares people away from Linux and back to Windows. :?|

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: