Most of you have probably at least heard of “grub” but may not be completely familiar with it. What it does or how to make it work for you is quite another story for most people. I’d like to outline a few minor tweaks that anyone can make to grub to update their boot-time options.
Your grub config on an Ubuntu system is outlined at /boot/grub/menu.lst. There is quite a lot of commenting in that file so, if you take the time to read through, you’ll should be able to figure out quite a bit on your own. I want to outline a couple things that I often tweak within grub.
First and foremost you should make a backup of the file before you make any changes. As always, there is a chance that you could make errors in your changes and it’ll save your day if you’ve made a backup. Make a backup using a command like:
sudo cp /boot/grub/menu.lst /boot/grub/menu.lst-backup
After you’ve made your backup copy you’ll want to edit the file to make a few changes. You would do that using the following:
sudo gedit /boot/grub/menu.lst
Now we get to the fun stuff! What to look at and what to change? So many questions. Below are some of the settings that can be changed within grub and what they do.
default – allows you to specify the default grub listing. This defaults to 0 and you generally don’t need to change this.
timeout – allows you to change the countdown before grub automagically boots into the default listing. By default it should be set to 3 (seconds). If you need more time to choose the kernel or OS to boot into you can change this. Simply change the entry from:
timeout 3
to something like
timeout 10
or, of course speed things up, setting it at
timeout 1
hiddenmenu – allows you to specify whether or not your grub menu will be hidden at boot time. By default it is hidden and prompts you to press ESC to see the menu. If you would prefer to see the menu each time you boot simply comment out the line. Example, you would change:
hiddenmenu
to
# hiddenmenu
The file then moves into some commented code to show you examples of listing and the style and options you can set. Below that underneath
## ## End Default Options ##
you’ll see the kernels or OS’ that you have listed for your system. These break down into four main options. This is an example of my current listing for the 2.6.17-10-generic kernel:
title Ubuntu, kernel 2.6.17-10-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.17-10-generic root=/dev/hda1 ro quiet splash
initrd /boot/initrd.img-2.6.17-10-generic
quiet
savedefault
boot
A few of these settings are optional but the required options are:
title – this is the menu listing you will see at boot. You can change this to whatever you’d like. An example could be:
title Ubuntu - The best distro ever! (2.6.17-10-generic)
(the reason that I listed the kernel version is so I can tell future updates or other customizations apart from this. You generally want to run the latest kernel and, in certain situations, run a previous. It is generally a good idea to list the kernel version in whatever “nickname” you set for your grub listing title.)
root – this is where the root of the file systems is located. Your partitions may be someplace on hda, but hd is the very root. You won’t want to change this but you might notice a difference if you’re running a dual-boot system.
kernel – the kernel option is where to find and what kernel to use for this option. If you create a custom kernel you’ll need to specify the path to that file. Or, in some situations you might be booting multiple distributions and in that case you’d need to specify the path to each kernel.
Also, the root option specifies the partition to find the distribution or OS files. This must be set correctly in order to find the kernel and other options.
ro, quiet and splash – these are optional but load the pretty splash screen that you see at boot time.
initrd – this loads the image that goes along with the kernel option above. The kernel (vmlinuz) and initrd (img) file are generally stored in the same place. Make sure that your paths match the exact file if you are customizing your menu.lst.
savedefault – this refers to the default option listed above. As this is our default option and latest kernel it is specified as such. If you take a look at your file you’ll notice the first listing is the only one with the savedefault option.
You should be a little bit more confident in tweaking your grub listing at this point. There isn’t a lot to it but it is one of the most critical system settings. If you ruin your grub file your system (or any system on your machine!) will not boot. Be careful with it but, as usual, your system is only as powerful as you are educated so take the time to know how your system runs. In most cases you wont need to edit grub, but for those of you feeling adventureous perhaps try to change the timeout setting or change the title for your options. Best way to learn is to try!
technorati tags:grub, boot, linux, ubuntu, breezy, dapper, edgy
How do I make it show me what’s happening while booting along with a usplash screen, as Ubuntu used to in the good old days? The only way to see that information is to get rid of the splash screen entirely, it seems….
Two points: first, on edgy the root partition is referenced via UUID (it looks like “root=3243-a6372…”). Second, the menu.lst file is generated each time a new kernel is installed, therefore some modifications will possibly be overwritten by future updates.
The right way to configure kernel options is to modify the part of the menu.lst file between the “Start Default Options” and “End Default Options” comments. To remove the boot splash for instance, change the (commented) “defoptions” variable. Then run “sudo update-grub”, which will find all available kernels and create “real” entries in menu.lst, to which it will append the options from the commented statements in the options section. See the man-page of update-grub for more details.
Sorry, need to correct myself: on edgy, the root filesystem is defined like this: “root=UUID=3243-a6372…”. Since filesystems are also referenced with their UUID in fstab, they can be mounted correctly no matter on which disk controller or USB port they are connected.
Pingback: randomthings Tweaking grub settings : Ubuntu (5.10 / 6.06.1 / 6.10) «
As a side note, I think it’s important to mention that, if you do manage to completely mess up your grub.conf file to the point that your machine won’t boot, you can fix it by booting into a livecd (like the Ubuntu livecd or Knoppix or DSL or *something*), and then copying your backup grub.conf over while in there. In fact, this method is great whenever you do something to your system that makes it temporarily unusable.
Nice work on the tutorials! One of these days I need to get one up on tweaking /etc/sudoers 🙂
In reply to hastesaver’s question:
If you remove the quiet option from the kernel line the messages will appear in the splash as they used to prior to Edgy.
Don’t forget vga=791 for small fonts in console.
My example:
kernel /boot/vmlinuz-2.6.17-10-generic root=/dev/sda7 ro vga=791 acpi=off splash=verbose locale=pt_BR
Sorry..my english is terrible..:D
best regards,
—
lao (Brasil – São Paulo/SP)
Pingback: Editing /boot/grub/menu.lst to change the GRUB boot menu « boff
Oddly, my copy of Edgy (installed from the 6.10 Desktop CD) includes the line “root=dev/hdc1” but my copy of Feisty (from Herd 2 Alternate Desktop CD) has the UUID line.
I only discovered this when, after cloning the drive and, without thinking, putting the new drive onto the primary controller instead of the secondary one where the old one had sat, Feisty booted fine but Edgy hung. (Feisty’s grub is the main boot menu & chains to Edgy’s grub if I select the right entry off the menu).
Fortunately I had both systems set up to cross-mount each other’s partitions as “/other” so I was able to boot Feisty, edit /other/boot/grub/menu.lst, reboot and everything was fine. Not often things work that well for me!
One odd thing I noticed. The data in the Edgy ‘automagic’ section had both the hdc1 line *and* the UUID but update-grub had chosen the hdc1 line – causing the problem. My Feisty automagic section only contains the UUID line.
Quote: “root – this is where the root of the file systems is located.”
I think it is not but simply where grub is supposed to find its files.
It is determined when we enter “find /path/to/stage1” using grub in a terminal on a LiveCD. It returns (hdx,y) which is now the root for grub, not the distro(s).
Two cases:
1_ /boot is a subfolder of the root partition /. The root for grub is then /boot and we type “find /boot/grub/stage1”.
2_ /boot is a separate partition from /. Then root for grub is /boot and we type “find /grub/stage1”.
Using the result, the command root (hdx,y) sets the root for grub. Now we can place grub’s MBR on a hard-drive with “setup (hd0)” to be run by the BIOS or on its own partition with “setup hd(x,y) which then must be chainloaded first with another boot manager on (hd0) to be seen by the BIOS. Because the BIOS is only able to boot this one (first sector on first hd equals (hd0)).
Just my 2 cents…
Errata:
1_ /boot is a subfolder of the root partition /. The root for grub is then / and we type “find /boot/grub/stage1″.
Sorry!
what setting in menu.lst do i need to centralise the splash screen? when ubuntu boots up, the splash screen is to the right of the monitor but is fine when booted.
>>>> ro, quiet and splash – these are optional but load the pretty splash screen that you see at boot time.
yes and no
as written by mcduck in http://ubuntuforums.org/archive/index.php/t-90230… :
"splash" enables/disables the graphical boot. "quiet" reduces the amount of messages outputted to screen during boot. If the splash is enabled but you remove "quiet" you'll get the graphical boot _with_ scrolling boot messages. 😮 . Remove "splash" and you get the traditional Linux boot-up with loads of scrolling text.
and i will add that the "ro" option is to mount the boot partition as "read-only" at boot time (only)
On ubuntu 9.1 and above the instructions have changed http://digitalpbk.com/2009/11/changing-default-bo…