ubuntu dual boot illustrated site ubuntu dual boot windows 7 maverick meerkat
Legacy GRUB Page
(GNU-GRUB 'Legacy' - meaning versions 0.97 and earlier)
Edited Tuesday, March 09 2010 Document made with KompoZer

This web page is about  GNU GRUB 'Legacy', and in particular how it can be used in Ubuntu Linux.
GNU GRUB 'Legacy' is the 'old GRUB' ,  used in versions of Ubuntu earlier than 9.10 Karmic Koala.
Information in this web page mainly applies to Ubuntu Hardy Heron, Intrepid Ibex and Jaunty Jackalope users.

Users of Ubuntu 9.10 'Karmic Koala' and later will be booting with the 'new' GNU GRUB, popularly called  'GRUB 2',  (actually GRUB 1.97).  The 'new' GRUB is quite a lot different from the 'old' GRUB. Ubuntu Karmic Koala users should got to this website's GRUB2 pages, GRUB2 Pages.

This web-page is part of a larger site giving examples of how to install Windows+Ubuntu Linux operating systems 'dual boot' in a computer.  Illustrated Dual Boot HomePage



 Ubuntu 8.10 kernel 2.6.27-7-generic                   
 Ubuntu 8.10 kernel 2.6.27-7-generic (recovery mode)
 Ubuntu 8.10 memtest86+
 Other operating systems:
 Microsoft Windows XP Home Edition





Use the up and down keys to select which entry is highlighted
Press enter to boot the selected OS, or 'e' to edit the
commands before booting, or 'c' for a command-line.

The highlighted entry will be booted in 10 seconds.
This is GRUB's main menu which we normally expect to see each time we boot our dual boot computers. It doesn't appear in computers with only one operating system because in that case it's not really needed.

The grub menu is very simple to use, even for beginners.
All that is necessary for most people to do is press your 'Enter' key.
If you don't press 'Enter', your favorite operating system will boot anyway after a number of seconds.
If you want more time you can press any key to stop the count-down timer while you think it over and make a decision.
When you're ready, just use your up or down arrow keys to highlight the line representing the operating system you want to boot and then press your 'Enter' key to boot your selected operating system.

Most of the time those are the only things you need to know to be able to boot with GRUB.
 
However, GRUB, (GRand Unified Bootloader), is much more than just an ordinary boot loader.  
If you ever want to do something special, or if you have trouble booting,  there are a lot of options available in GRUB to help you,

1) GRUB can load a wide variety of operating systems directly by loading their kernels into the computer's memory.

2) GRUB can load 'proprietary' operating systems (unsupported operating systems like Windows) by a process called 'chainloading'.

3) When you are installing a new Ubuntu operating system, the Ubuntu installer runs programs to detect other operating systems in your computer and it sets up GRUB automatically for you.
Most of the time the installation scripts work perfectly and all of their other operating systems will boot.
Due to various computer technical difficulties, some computers give the wrong information and a small correction will be needed to an operating system's entry in the menu.lst file. This doesn't happen all that often when it does happen the computer users who are affected tend to make a lot of noise in web forums about it. At least they should be thankful that GRUB was set almost perfectly for them automatically. Other operating systems have boot loaders that need to be set up manually every time if you want to dual boot.

4) The GRUB Menu is completely customizable to suit different computers and individual preferences. The GRUB menu and much of GRUB's behavior is controlled by our /boot/grub/menu.lst (menu list) text files. I'll show you how to find that and some of the things you can do with it further down this page.

PAGE INDEX

Orientation. - a guided tour of some of the most important files needed for booting Linux.

GRUB's Main Menu. - the GRUB menu that you normally see at boot time.

GRUB's Command Line Interface. - GRUB can function as a miniature operating system.

Temporarily Edit the GRUB Menu. - how to edit your GRUB  menu commands 'on the fly'.

Using the GNU/GRUB shell. -  GRUB as a program when the operating system is running.

memtest86+. -it isn't really part of GRUB but it's accessed from the GRUB menu and I like it.


Customizing Your GRUB Menu. - Edit your /boot/grub/menu.lst file, personalize your GRUB.


How to make a dedicated GRUB partition.-  contains only GRUB, no other files  are required.

How to make a separate /boot partition.-contains the Linux kernel, initrd.img and GRUB files.

How to add GRUB to your USB thumb drive. - GRUB in a USB stick  makes a great pet.

How to make your own personalized GRUB Floppy Disk. - you can  play with it and have fun.

How to make your own personalized GRUB CD-RW. - portable - boots in almost any computer.


Re-install GRUB with a GRUB shell. - re-install GRUB from anywhere to anywhere with anything.

Re-install GRUB....................................with the Alternate CD in Rescue mode.

How to back up and restore your MBR. - with a dd command from a live CD.

   Trouble Shooting Section:   Common Booting Errors and Some Possible Cures 


LINKS
The Linux Boot Process - a summary of what is supposed to happen before the login prompt

Here's the link to GNU GRUB's homepage
 
Here's a link to the GNU/GRUB manual, it has lots of good information in it you can refer to.
Also, here is GNU GRUB FAQ

Here are some more links to some other great websites about GNU/GRUB,
GNU GRUB Wikipedia,
Grub Grotto by Steve Litt,
GRUB tips and tricks by Jeremy Turner,
Boot with GRUB by Wayne Marshall, Linux Journal.


Orientation 
Here's where to find some important files to do with booting.
I'm assuming you have Ubuntu or a similar Linux operating system up and running and you're just sitting there staring at your desktop.

To start this tour, you go 'Places'-->'Home Folder', and then look for the 'Up' arrow two times to go up two levels in the file system, to the top of our directory tree.
This what we call the 'root' of our file system.
It's the big main directory (folder) that contains all the rest of them.
Very often the forward slash:  /  , is used for short, to indicate the root file system, instead of typing out the word 'root' every time.
Besides, there's also a directory there called: /root , and we don't want to confuse anybody.
                                   
fig4grub   
fig 4 GRUB
In the top row of folders there's the /boot directory, we'll look inside that in a minute.

While we're here, notice the two files in the bottom row?
Those are 'symlinks', (shortcuts), to the Linux kernel and initrd.img files.  Sometimes we use those for booting with when we don't know the exact name and location of the kernel and initrd.img. 

 

When, you open the /boot directory it should look something like the illustration below.

fig5grub
fig 5 GRUB
The files called vmlinuz-2.6.12-9-386 and initrd.img-2.6.12-9-386 are the Linux kernel and the matching initrd.img that belongs with it.

The Linux kernel is the nucleus of  the operating system.
GRUB needs to be able to load this kernel into the computer's memory to boot the system.
Read more about the Linux kernel:  The Linux Kernel (tldp.org, David A Rusling).

The initrd.img helps the kernel get started, it's something like a road map of the file system or maybe more like a miniature model of it that the kernel loads until it is able to load the real file system. Read more: initrd (Wikipedia).
The initrd and the kernel are a matched pair, we always have an initrd with the same numbers after it's name as the kernel it belongs to.

/sbin/init - very important, (but not shown here), init is a program that is vital for booting. It's the first thing the kernel runs, init runs other scripts needed for booting including /etc/rc scripts.
Here are two links about init, Replacing init with Upstart - linux.com, and Ubuntu's Upstart event-based init daemon - linux.com


See the folder named 'grub'? Open that one now...

fig6grub
fig 6 GRUB
And here's a look at what you should see inside your /boot/grub directory.
 
These files are your important GRUB files needed for booting your Linux kernel.

GRUB's stage1 file is a copy of the one that gets installed in the MBR, (sector 0 of any hard disk).
This file is 512 bytes in size, the size of one sector. I don't know why it's 512 bytes.
The MBR is 512 bytes in size, but 64 bytes are reserved for the partition table, 2 bytes for the 55 aa bootable disk flag, plus there's the 'Disk signature', which GRUB preserves, and possibly some other bits and pieces of code that has to avoid being trampled. The bootloader code has to be far less than 446 bytes to fit in the MBR.

There are six of the stage1_5 files to choose from. Those are the files that GRUB installs to the next twenty-one sectors of the first track of the hard disk, right after the MBR.
The jobs of GRUB's stage1 and (optional) stage 1_5 files are just to 'point to' GRUB's stage2 file in a file system somewhere in a hard disk partition, or if  they can't, print an error message.
GRUB's stage1 can also (or instead), be installed to the first sector of a partition, (called a boot sector). In that case the stage1_5 doesn't go with it, (except if the partition is formatted with ReiserFS).

GRUB's stage2 file can be seen in the above screencap. The stage2 file is the main part of GRUB. That's the big GRUB file that does all the heavy lifting to get the kernel loaded into the computer's memory and boot it. The stage2 file I have is 108 KB, according to the output from the command 'ls -lhS /boot/grub', in my terminal. That's by far the largest file in this directory.

Please read this brief and excellent  link about GRUB's stage1, stage1_5 and stage2 files:   
Grub's stage2 file refers to our /boot/grub/menu.lst file for instructions to bring up our GRUB Menu for us at boot-up which offers us a list of operating systems to choose from.
NOTE: That's 'menu.lst', with an 'L', not a '1', it's short for 'menu.list', not 'menu.first', (a common newbie mistake, I got caught with that one myself when I was new here, (LOL)).

When we select an operating system we want to boot from our GRUB menu, we're really selecting the list of commands in our menu.lst file pertaining to that operating system. The stage2 file then uses those commands and goes into action to boot it.
That's why the /boot/grub/menu.lst file is the most interesting of GRUB's files for most of us.
It's GRUB's 'configuration file'. That's the one that we can edit to change our GRUB settings order to get your computer booting exactly the way we want.

Another file in there that's interesting to people whose computers have more than one hard disk, is the /boot/grub/device.map file. That one shows us which hard disk GRUB thinks is our first hard disk and which hard disk GRUB thinks is our second hard disk and so on.

 You can't just open your /boot/grub/menu.lst file and change it and expect to be able to save the changes. That won't work in Ubuntu because of the Linux file permissions (security settings).
We can edit our /boot/grub/menu.lst file if we open it from the command line.

Open your terminal, go 'Applications'-->'Accessories'-->'Terminal' and either copy the command I used out of the code box below and paste it in yours or type it yourself if you prefer.
Don't include the 'herman@bookpc:~$' part though, only the command after it.
If you're typing your own command out by hand, make sure you realize that's an 'L' for 'list', not a '1' in the filename: menu.lst. New users often find that a little confusing.

Actually, you can use 'tab completion' instead of typing entire commands. Just type the first two or three letters of the file name or command, then press your 'tab' key. Most of the time the terminal will guess correctly what it is you want to type and finish it for you.
Code:
herman@bookpc:~$ sudo cp /boot/grub/menu.lst /boot/grub/menu.lst_backup
That makes a backup copy of our /boot/grub/menu.lst file and saves it as /boot/grub/menu.lst_backup.
We always make a backup copy, especially the first time we edit any important configuration file.

If you ever need to restore your /boot/grub/menu.lst file, just reverse the command,
Code:
herman@bookpc:~$ sudo cp /boot/grub/menu.lst_backup /boot/grub/menu.lst 

Now we'll open the file,
Code:
herman@bookpc:~$  gksudo gedit /boot/grub/menu.lst
After typing that into 'terminal', you'll be prompted for your password.
After typing your password in, the menu.lst text file will open in your monitor.


Customizing your GRUB Menu
by editing GRUB's menu.lst file

You can make your computer temporarily unbootable if you make a mistake editing your /boot/grub/menu.lst file.
Don't let that scare you though, editing your /boot/grub/menu.lst file is fun. It's a bit like learning how to ride a bicycle though, you might 'fall off' a few times at first.
It's interesting and educational to play with the commands in GRUB's menu.lst file. For some people it will be their first introduction to computer programming.
Don't worry, it's easy. I'll show you what to do.

Tip: Before editing your /boot/grub/menu.lst file you can go and download a Super Grub Disk CD, floppy or USB image to make an emergency boot disk with. I recommend having a copy of Super Grub Disk on hand for booting with in case you make a mistake and accidentally make your computer temporarily unbootable in the normal way.

Super Grub Disk Homepage - Official Super Grub Disk Website (external link)

Super Grub Disk Page - this website's Super Grub Disk help page

Below here is an example /boot/grub/menu.lst file.
It contains most of GRUB's commands in roughly the order you'll see them appearing in your own /boot/grub/menu.lst files.
I have hyperlinked each command so that you can click on each one to take you to an explanation about what each command does and how to use it.
# menu.lst - See: grub(8), info grub, update-grub(8)
#            grub-install(8), grub-floppy(8),
#            grub-md5-crypt, /usr/share/doc/grub
#            and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not change this entry to 'saved' or your
# array will desync and will not let you boot your system.
default        0

#fallback 5 6 7 8
## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout        10

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu
# Pretty colours
#color cyan/blue white/blue


splashimage=(hd0,1)/boot/grub/Ubuntusplash.xpm.gz
foreground ffe4b5
background f4a460


## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line)  and entries protected by the
# command 'lock'
# e.g. password topsecret
#      password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title        Windows 95/98/NT/2000
# root        (hd0,0)
# makeactive
# chainloader    +1
#
# title        Linux
# root        (hd0,1)
# kernel    /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
##      kopt_2_6_8=root=/dev/hdc1 ro
##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=UUID=fe7bf845-7ce9-4733-b6de-f70f2b62076d ro

## default grub root device
## e.g. groot=(hd0,0)
# groot=fe7bf845-7ce9-4733-b6de-f70f2b62076d


## should update-grub create alternative automagic boot options
## e.g. alternative=true
##      alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
##      lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
##      lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
##      altoptions=(recovery) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
##      howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
##      memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## ## End Default Options ##

title    Ubuntu, kernel 2.6.20-15-generic
uuid     fe7bf845-7ce9-4733-b6de-f70f2b62076d
kernel   /boot/vmlinuz-2.6.20-15-generic root=UUID=fe7bf845-7ce9-4733-b6de-f70f2b62076d ro quiet splash
initrd   /boot/initrd.img-2.6.20-15-generic
quiet
savedefault

title    Ubuntu, kernel 2.6.20-15-generic (recovery mode)

uuid     fe7bf845-7ce9-4733-b6de-f70f2b62076d

kernel  /boot/vmlinuz-2.6.20-15-generic root=UUID=fe7bf845-7ce9-4733-b6de-f70f2b62076d ro single
initrd  /boot/initrd.img-2.6.20-15-generic

title        
Ubuntu, memtest86+

uuid     fe7bf845-7ce9-4733-b6de-f70f2b62076d

kernel        /boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title        Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title        Microsoft Windows XP Home Edition
root        (hd0,0)
savedefault
makeactive
chainloader    +1


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sdb1
title        Windows 95/98/Me
root        (hd1,0)
savedefault
makeactive
map        (hd0) (hd1)
map        (hd1) (hd0)

chainloader    +1

###############################################################
# Additional GRUB tricks for fun, security, and convenience

# below here are some lesser known commands some (silly)? ideas

# added by me - these are not part of your stardard menu.lst
#
(you can try them out if you like)
###############################################################

title     Pretty colours
color     cyan/blue white/blue
title     Matrix

color
     green/black blink-light-green/green
title     Green and Gold
color     black/green yellow/black
title     Leonardo Watermelon

color
     black/magenta white/red

title      Your Boot Message Title Here
cat        (hd0,1)/boot/grub/bootmessage
pause      End of Boot Message, Press any key.

title     Windows Security Check
root      (hd0)
cmp       63+1 24306344+1
title     

Reboot
reboot

title      HALT!
halt
fig 7 grub
Above here is an example of a /boot/grub/menu.lst file.  
It should be fairly typical for a dual boot computer with one hard disk. (Except for a few lines I added at the bottom for fun).
It might look a little scary to a new user when you see it all in one big piece like this. Below here I will be showing snippets of this beginning from the top and working our way down. I will point out the parts that can be edited by the user and comment on how to do so.



How to Change the Default -
set which operating system you want booted by the timer

# menu.lst - See: grub(8), info grub, update-grub(8)
#            grub-install(8), grub-floppy(8),
#            grub-md5-crypt, /usr/share/doc/grub
#            and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not change this entry to 'saved' or your
# array will desync and will not let you boot your system.
default        0


fig 8 grub
The number after the default command sets which operating boots by default when the countdown timer reaches 0 if no keys are pressed on the keyboard.

For dual booting with certain operating systems that seem to require rebooting very often, it can be a real pain in the neck after a while to have to be there and manually intervene every time the computer reboots.

There are three possible ways to set this, choose the one you like best,
  1. Paste your Windows entry above the beginning of the debian automagic kernels list
  2. edit the number for the operating system entry to be booted (by the timer)
  3. edit the number and type 'saved' there instead.
1) Paste your Windows entry above the beginning of the debian automagic kernels list
You can cut the entire Windows entry from where it is under the end of the automagic kernels list and paste it above the beginning of the automagic kernels list.
 Above this line: ### BEGIN AUTOMAGIC KERNELS LIST   

What NOT to do-  don't paste your Windows entry anywhere inside the automagic kernels list because it will be deleted when you have a kernel update in Ubuntu.

2) edit the number for the operating system entry to be booted (by the timer)

This little line controls which operating system boots by default, Ubuntu or some other operating system entry like another Linux, or Windows.
If you really want to have some other operating system booting first by default, you need to have a look at the bottom section of your menu.lst file at the operating system entries.
Ubuntu is entry number 0 because the GRUB numbering system begins counting from 0.
(From the top of the list,counting down).
To see the area I'm referring to, look at either,
(a) the bottom  of fig 7, (scroll up to see that)  
or  (b)  see the whole of fig 14 below, click here).
Count down from the top, (from just below where it says '## End Default Options ##').
Begin counting with the number 0,  the number of entries containing the word 'title'.
You don't count the entries the are 'hashed out' (with a # in front of them, skip those).
Stop counting when you reach the Windows entry, and that number you end up with will be the right number to replace the number  0 with after the word 'default'.

In this example, it will be the number 4 which you would use in place of the 0 after the word 'default' to cause Windows to boot by default.
That would most likely be true for  the majority of standard dual boot installations.

Windows is behind the fifth appearance of the word 'title'. Don't forget, you start counting from the number 0. So it's not 1,2,3..., it's 0,1,2,3..., okay? Count each time the word 'title' appears and in this example you will see that Windows is number 4 (counting from 0).

Don't be afraid to experiment if you aren't sure, this won't hurt anything if you don't get it right.  All this setting does is make the highlight rectangle in the GRUB menu appear on a different line, that's all. You can easily change that again if it turns out wrong. It's a safe line to edit.

3) Edit the number and type 'saved' there instead.
Use this method if you want to avoid having to re-edit menu.lst when you have a new kernel added to the list during an update. (Thus changing the number that your default operating system is on the list).

Rather than just replacing the number '0' in the line, 'default    0'  with another number, you can type the word saved in place of the '0'.
For example:    
default        saved
That will cause GRUB to remember whatever menu entry you booted last time.
The highlight (selection) rectangle in your GRUB Menu will appear on that line again next time you reboot.

The way this works is by use of the command 'savedefault', included in most GRUB operating system boot entries at the bottom of menu.lst.
When we type 'saved' rather than a number here, after 'default', it causes GRUB to save that information to the /boot/grub/default file and refer to it next time we boot. 
 
Most people would be content with that, however, if even this isn't good enough for you, it is possible to take the idea one step further and make GRUB boot only one operating system by default.
Here is how to trick GRUB to only remember one particular operating system entry.
Just place a # (hash mark) in front of the 'savedefault' command in the other operating system entries (at the bottom of your menu.lst), that you do not want GRUB to remember.
Then GRUB will only be able to remember (save) the operating system entry that does not have the # mark in front of the 'savedefault' command.



4) fallback
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not change this entry to 'saved' or your
# array will desync and will not let you boot your system.
default        0

#fallback 5 6 7 8

The fallback command doesn't appear in Ubuntu's GRUB menu by default, it's a less well known command I have added here just to show everyone how to use it.
For this fallback command to work, you would need to delete the '#' (hash symbol).
You would probably need to make up your own numbers to put after it too. The numbering protocol for the fallback command is the same as the 'default' command uses, (already explained above), (scroll up).

When the fallback command is used, if the first booting entry, (number 5 in this example), fails for some reason, GRUB will read stanza number 6, (the seventh stanza), and run those commands instead. If that boot entry fails, GRUB will try the next boot entry, and so on.

When the 'fallback' command is used, GRUB goes into 'unattended boot mode'. If GRUB encounter an error it wait for the user to do something, it just skips right ahead to the next boot entry.
The trouble with that is, you aren't given an error message, so it's not a command that we would want to use all the time for every-day booting.

The fallback command can be very useful if you are having problems booting some other operating system, (Windows or a different Linux), and you already know your GRUB Error message, but you're not quite sure of the exact solution to your problem.
You can make a whole series of trial boot entries at the bottom of your menu.lst, each with different (hdx,y) numbers in them say for example.
Using the fallback command, GRUB will run through the whole list, trying each boot entry until it finds the one that works and then boot the operating system.
That can save you a lot of time. This avoids the need to keep rebooting a live CD or something and re-editing your menu.lst file, possibly numerous times. That can be a very time consuming process.

How will you know which boot entry worked?
You could insert the 'pause' command in each of your boot entries with a short message to inform you of which entry is which. That will stop GRUB at each entry until you read the message and press 'enter'. The 'pause' command puts GRUB back into 'interactive mode' again and that means you'll see any error messages too!

The way I have it set up here, this command will only work for GRUB errors. Once operating system begins to boot it's out of GRUB's hands if anything goes wrong after that and it's too late for the fallback command to do anything.
Instead, you can put the 'fallback' command in your individual operating system entries, see: Booting fallback systems - GNU GRUB Manual. Then the fallback command will even work when you have booting problems in the operating system.



4) Setting the timer
for the boot loader is the next subject.
#fallback 5 6 7 8

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout        10
fig 9 GRUB
Following the word timeout above, you'll see the number 10. This sets the timer for the boot loader to boot the default operating system if no-one presses any buttons on the keyboard.
We can delete the number 10, and in its place type in any number of seconds we'd prefer the timer to be set to.
If we want the computer to boot without waiting so long we can set it to a lower number of seconds like maybe 3, 2 or even down to 1second.
If you are also 'hiding' the GRUB menu, you will have 3, 2, or 1 second to press 'Esc' to show the menu.
To make the GRUB menu wait longer, type a larger number in place of the 10.
If we want to turn off the timer, so that we will have an infinite amount of time to admire our GRUB menu and ponder which operating system we might want to boot today, we just 'hash out' the whole line for the timer.
To 'hash out' the line, we insert a # mark before the commands and this will cause the program to ignore the whole line. Then the GRUB menu will theoretically wait forever until you make a decision, select an operating system, and press enter. (Or until there's a power failure).

WARNING:
Don't set the timer to 0 seconds if you also have Windows set as the default boot option or you might not be able to boot Ubuntu anymore.
If you can't boot Ubuntu anymore, then you won't be able to come back and fix your menu.lst file, so you'll make your Ubuntu system unbootable.
(Unless you are clever enough to be able to think of some other way to boot Ubuntu or access and edit /boot/grub/menu.lst from a LiveCD). Click Here to see how.
Tip:
You can use Super GRUB Disk to boot your computer with if it becomes accidentally unbootable due to some error you may make while editing menu.lst

Super Grub Disk Homepage - Official Super Grub Disk Website (external link)

Super Grub Disk Page - this website's Super Grub Disk help page



Hiding the GRUB menu during bootup

timeout        10
## hiddenmenu
# Hides the menu by default (press ESC to see the menu)

# hiddenmenu
fig 11 grub
The word: hiddenmenu is a grub command.

In computer programming, it is often a good idea to add a comment to advise people reading the program what is going on at certain points in the program.
There are special symbols in various programming languages that are used to denote a comment.
In the case of GRUB's menu.lst and many other files that we edit in Ubuntu, the # symbol is a sign that tells the computer that the words after it are to be treated as comment, and not a command. In other words, they are to be ignored (skipped) by the computer.

# - Hides the menu by default (press ESC to see menu' is a good example of a comment.

# hiddenmenu  - is an example of a command that will be treated as a comment (ignored) for now.

If we want the computer to pay attention to the hiddenmenu command and to hide the GRUB menu on start-up, we could 'uncomment' the  line with the hiddenmenu command on it by deleting the # symbol.
Then we will not see the GRUB menu when the computer boots from now on.

Example:
 hiddenmenu
Some people want to set up GRUB this way when they need to share the computer with others in the office or home who just want to boot Windows and may be distressed by the unexpected appearance of the GRUB menu. (They wouldn't know what to do).
With 'hiddenmenu' activated, they will just see a black screen with a small timer on it.  If you want to make a good job of it, set the timer down to 1 or 2 seconds and set the grub menu to boot Windows by default. The black screen will be there and gone again before anyone has time to notice it. No-one would even guess that GRUB and Ubuntu were in the computer at all.
When you want to boot into Ubuntu, press your 'esc' key during this 1 or 2 second count-down, to show the GRUB menu and select Ubuntu.



Add some color to your GRUB menu

# hiddenmenu

# Pretty colours
# color cyan/blue white/blue

fig 12 grub
GRUB's color command changes the menu colors.
The line for color can be uncommented ( delete the # ) and that will cause the GRUB menu that we see when the computer is starting up to appear in pretty colors, instead of just plain old black and white.

The colors cyan/blue white/blue are only the defaults, (example colors).
There are quite a few other colors you can use, and you can make up your own combinations.
To do that,  just delete the colors given there as an example and type or type or copy-paste in your own color combinations.

An easy way to experiment with the different color combinations for your GRUB menu is to use GRUB's freindly Command Line. That's a lot easier than editing your menu.lst file and rebooting every time

Press 'c' from the GRUB menu when your computer is booting to get  GRUB's Command Line Interface
Type the word color as a command, followed by some colors you want to try.
Syntax for the color command is : color normal [highlight]
and the format of each heading is: foreground/background

For example,
grub>  color light-gray/red blink-white/black

Press 'Enter', then press 'Esc' to go back to your menu and see what your GRUB menu looks like with the colors you're testing.
Then press 'c' again and try some different colors, and so on until you decide on the colors you want.
When you have decided on a combination you like, boot Ubuntu and edit your /boot/grub/menu.lst with your chosen colors.

normal 
foreground/background
(most lines in the menu / table background color)
[highlight]
foreground/background
(selected text / cursor bar)
any of these sixteen color names can be used for foreground (normal text & table border)

black
blue
green
cyan
red
magenta
brown
light-gray
dark-gray
light-blue
light-green
light-cyan
light-red
light-magenta
yellow
white
any of these eight color names can be used for background (normal table area)

black
blue
green
cyan
red
magenta
brown
light-gray

any of these sixteen color names can be used for foreground (hilighted text)

black
blue
green
cyan
red
magenta
brown
light-gray
dark-gray
light-blue
light-green
light-cyan
light-red
light-magenta
yellow
white

You can prefix blink- to foreground if you want a blinking foreground color
any of these eight color names can be used for background (selection bar area)

black
blue
green
cyan
red
magenta
brown
light-gray


Some of the color combinations I have tried are listed below.
 
command          font&border/panel         hilited font/cursor (selection bar)
color           black/brown                  blink-yellow/black
color           black/green                   yellow/black
color           light-green/green          blink-yellow/red
color           black/magenta             white/red
color           white/red                      light-gray/black
color           light-gray/blue              black/light-gray





Ubuntu 8.10, kernel 2.6.27-7-generic                  
Ubuntu 8.01, kernel 2.6.27-7-generic (recovery mode)
Ubuntu 8.10, memtest86+
Other operating systems:
Microsoft Windows XP Home Edition


   Use the up or down arrow keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, or 'c' for a command-line.


NOTE: We cannot have a pretty color grub menu and also a splashimage simultaneously, we need to choose one or the other.



Add a splashimage to the GRUB menu


# Pretty colours
#color cyan/blue white/blue


splashimage=(hd0,1)/boot/grub/Ubuntusplash.xpm.gz

foreground ffe4b5

background f4a460
fig 10 GRUB
You can customize your GRUB with a nice splashimage (picture) for your GRUB Menu.
You can either find one you like that someone else has already made and downloading it from the internet, or even make your very own unique one with GIMP!

If you want to have fun making your own splashimages, I have help on how to do that further down this page. Link: Making your own splashimage

If you like any of my splashimages (below) and if you trust this site, you are welcome to download any of my splashimages shown here for free.
Do so at your own risk. I am sure they are safe, I made these myself.
(But I copied the canonical logos and colors, I hope that's okay).


Ubuntusplashthumbnail Kubuntusplashthumbnail Xubuntusplashthumbnail
Ubuntusplash.xpm.gz
Kubuntusplash.xpm.gz
Xubuntusplash.xpm.gz

EurekaFlagthumbnail AboriginalFlag
p15/nightshipThumb.png
EurekaFlag.xpm.gz
Download
The Australian 'rebel' flag, from the miner's strike at Eureka Stockade in 1854.
AboriginalFlag.xpm.gz
Download
try it with fg&bg settings,
foreground ffff00
background 800000
nightship.xpm.gz
Download
looks best with fg&bg settings,
foreground 87ceeb
background 0000ff

p15/eeepcsplash.pngp15/moonlight.voyager.pngp15/jaunty.dot.jackalope.thumb.png
eeepcsplash.xpm.gz
Download
This is my EeePC splashimage
I use fg&bg settings,
foreground 8b2323
background ee8262
moonlight.voyager.xpm.gz
Download
This is der Duyfken, in which Captain Willem Janszoon and his crew discovered Australia in 1606. Historic link
jaunty.dot.jackalope.xpm.gz
Download
Aboriginal dot painting of an Australian jackalope fighting a crocodile

LINKS
Here are some nice websites  where you can download more splashimages already made for you, McGrof'sschultz-net, and schragehome.de
  
This one's a good link, it has lots of nice ones: GNOME-Look.org

Here are some links from Ubuntu Web Forums with nice splashimages you can download
Post your GRUB bootsplash image!
GRUB Boot Splash Screens
GRUB 0.97 and splash screens
Kubuntu Widescreen GRUB Splash
How to: GRUB Splash Image
HOWTO: GRUB splash images.
simple human GRUB splash

When you have downloaded your splashimage and moved it or pasted it into your /home/username directory, you will need a 'sudo' command to copy it to your /boot/grub directory.

Code:
herman@bookpc:~$ sudo cp Ubuntusplash.xpm.gz /boot/grub
And the above command copies my new grub splashimage to my /boot/grub directory.

Then you need to open your /boot/grub/menu.lst file with your text editor (gedit), also using a 'sudo' command,

Code:
herman@bookpc:~$ gksudo gedit /boot/grub/menu.lst

and insert a line similar to the following,
Code:
splashimage=(hd0,1)/boot/grub/Ubuntusplash.xpm.gz
Where: Ubuntusplash.xpm.gz is the name of my splashimage and it is located in my (hd0,1) partition, in my /boot/grub directory. You may need to change this command to suit yourself if your splashimage has a different name or is in a different location.
Note: If you make a mistake in the splashimage line in menu.lst, it can cause you some temporary booting problems until you correct your mistake. You might need to boot with Grub's Command Line Interface or a Super GRUB Disk  to get access to the menu.lst file again so you can correct it.
Another way to get out of difficulty is to run a live cd such as Ubuntu Desktop, Knoppix, Puppy Linux or the like, and mount the Ubuntu partition and edit the file that way. Mount a Ubuntu ext3 or reiserfs filesystem rescue your Linux system with a Live CD

It is not unusual for inexperienced new users or even careless old experienced users to have a few hiccups with getting the command right, but once you get it all done correctly you will have a nice splashimage showing behind your GRUB menu.


Making your own splashimage

The excellent instructions in the following link, http://ruslug.rutgers.edu/%7Emcgrof/grub-images/, will tell you how to do everything with splashimages. That's the original and best GRUB splashimage site. That's the one I got all my information from, and is well worth reading.
The only problem with that site is that the instructions were written for Red Hat Linux and need to be altered a little bit to work for Ubuntu users. Experienced users will have no problems, but for the sake of new users I'll explain some it again here in Ubuntuese to make it easier.

Overview:
Due to the fact that the operating system will not have started yet at the time the GRUB splashimage will be displayed, the operating system's graphics drivers will not be in operation yet. Therefore we are just relying on the simpler video capabilities of the BIOS. Since most computer's BIOSes can't handle fancy, high quality images, we are limited to an image size of 640x480 pixels and a 14 color display, (unless your PC has some kind of special new BIOS).
The file type used for the image file is .xpm, and it is then compressed. This used to be done by applying a gzip command. An easier way to gzip a file in Ubuntu nowadays is to right-click on it, and click 'Create Archive', from your right-click menu.

Step 1:
Pick out an image to turn into a GRUBsplash. Any image file you might have will do, it can be a digital art work you made yourself, or even a picture taken with your own digital camera.

NOTE: Your picture will lose quality when you follow these steps.

Some pictures (photos) and digital art works that look great beforehand will look horribly ugly after they are converted into GRUB splashes. Only a few actually look better, so you can expect to produce a lot of rejects. You will need to use trial and error, patience, luck and good judgment until you learn how to choose images that can be turned into good GRUBsplashes.
I think the simplest images turn out looking the best, such as cartoons, cartoon characters on a plain solid background, or other kinds of digital art with sharp edges.
Even just one or two words in a nice font on a plain or colored background will do fine.
Because of the pixelation, scaley creatures like lizards and dragons or fish look good.
Black and white photos can be good, and can even be color- tinted for extra effect.

Step 2:
Make a copy of the image and work on the copy, preserving the original in good condition so you can make another copy of it and try again if things go wrong. Never use your original image file.

Step 3:
Open the copy of your image with GIMP in Ubuntu, and scale and/or crop the copy of your image until it's 640x480 pixels.

Step 4:Carefully examine your new image to see if it needs any editing, use GIMP to touch up any faults or flaws in your image.HINT: If you want to put some words in your splashimage in fancy text using GIMP, you should first look at 300+ Easily Installed Free Fonts for Ubuntu - Ubuntu Blog by Carthik Sharma, and follow the instructions there to install some beautiful fonts for your splashimage.Step 5:Go 'Image'-->'Mode'-->'Indexed', and set 14 colors as the Maximum number of colors, and set the 'color dithering' spinbox to 'None', and click 'OK'.
Then go 'File'--> 'Save as' and make up your own filename. Be sure to add an .xpm filename extension after it, click 'save', and you're all done. It's that easy!
For example, you might name it something like: bestgrubsplash.xpm
Any name will do as long as it has .xpm after it.

Step 6:
gzip your 640x480 pixel, 14 color .xpm image made with GIMP, here's the command I used to use to gzip mine, you should be able to use a similar command for yours, whatever it's name is,
code:
herman@bookpc:~$ gzip Ubuntusplash.xpm
Where: Ubuntusplash is the name of my .xpm file
Actually, nowadays you don't really need to use the command line for this job anymore. An easier way to gzip a file in Ubuntu these days is to right-click on it, and click 'Create Archive', from your right-click menu, then select .gz in the right-hand spinbox, and click 'create'.

Step 7:
Copy your .xpm.gz file to your /boot/grub directory.
You can actually leave your splashimage anywhere, even in your /home/username directory, as long as you type the correct file path for it into your menu.lst file. If you do leave it in your /home/username directory just remember not to accidentally delete, move or rename it. To avoid the chances of that happening it is probably best to copy it to your /boot/grub directory.
You definitely do need to use the command line for that,
code:
herman@bookpc:~$ sudo cp Ubuntusplash.xpm.gz /boot/grub/
And the above command copies my new grub splashimage to my /boot/grub directory.

Step 8:
Edit your operating system's /boot/grub/menu.lst file with a line to make your GRUB open and display your splashimage at boot time. I already showed you how to do that at the start of this topic, go back.

EXTRA TIPS:
To  look at your splashimages without taking the time and effort to edit your menu.lst file with each one and re-boot each time, you can load them with CLI mode GRUB when you are booting up. Just press your 'c' key for GRUB's Command Line.
Then, type something similar to the following,
Code:
grub>  splashimage (hd0,1)/boot/grub/Ubuntusplash.xpm.gz
Where: (hd0,1) is the partition number of the Ubuntu partition, and Ubuntusplash.xpm.gz is the name of a splashimage file which is located in the /boot/grub directory.
Then press 'esc' to return to your GRUB menu to see how it looks.
When finished, press 'c' again to return to the command line interface.
Type the path and filename of another GRUBsplash you want to look at and press 'Enter'.
Then press 'esc' to return to your GRUB menu to see how it looks.
And so on...

NOTE:  pretty color must be disabled (hashed out) in your GRUB menu or your splashimage will refuse to display. If you have problems, check and make sure you have your color lines all hashed out in your /boot/grub/menu.lst file.
We can however, change the colors of the foreground, background and border for the splashimage.  This can be very effective to compliment and show off an already good splashimage and make the finished job look superb! I highly recommend reading and trying out the instructions in the next article right below here on setting the foreground, background and border colors!


Setting the foreground, background and border colors
for your GRUB menu.
The following several commands only work in graphics mode GRUB (when you are using a splashimage). See 'pretty color' if you aren't using a splashimage.

We can use the commands 'foreground', 'background' and 'border' to specify the colors of the parts of our GRUB display that show up along with our splashimage.

'foreground' means the color of the main upper left faces of all letters and the big text rectangle that has all our operating system titles in it in our GRUB menu.

'background' sets the colors used in the lower-right 'shadowing' for all the letters and the big rectangle around our operating system titles and most importantly the hilite (selection) bar that we shift up or down with our arrow keys to select an operating system to boot.

'border' gives us a chance to set a color for any parts of the screen not used by the GRUB menu. In my computer I'm using 640x480 GRUB splashes that nearly fill the entire screen. There is a column on the left that shows up and a thin line across the bottom of the monitor that shows up if I set a 'border' color that is different from my splashimage. I could leave the border color black or pick a color that will blend in with the splashimage or one that will show up if I want that effect. I imagine if I use a smaller sized splashimage the border will show more.

You can pick any colors out of the sixteen color chart here in this sixteen color chart to begin with, but probably you'll want to use a 256 color chart instead ,that would be even better,
black000000green008000silverc0c0c0lime00ff00
gray808080olive808000whiteffffffyellowffff00
maroon800000navy000080redff0000blue0000ff
purple800080teal008080fuchsiaff00ffaqua00ffff

Here are links to sites that give us the codes for specifying 256 colors. Most computers these days should be able to display 265 colors in VGA mode. I have not tried all 256 colors yet, but I have tested enough to be pretty sure any of them will probably work very nicely.

256 Color Chart - Eloquent Vision

16 Color and 256 Color chart - Web Diner's


For example these can be applied something like this,
# Pretty colours
#color cyan/blue white/blue


splashimage=(hd0,1)/boot/Ubuntusplash.xpm.gz
foreground ffe4b5
background f4a460 

I added these two lines to my menu.lst file right under the splashimage command, although I think it can probably go anywhere.
That gives me 'moccasin' lettering with 'sandy brown' shadowing and selection bar over my nice chocolate and tan Ubuntusplash.

I chose yellow, ffff00 and maroon 800000 with my Aboriginal flag splashimage.


The 'shade' command toggles the shadows to the right-lower side of the rectangle and font.  
shade 0 turns off the shadow effect
shade 1 turns on the font shadows
So with this command you can now choose whether you want to see the font shadows or not.

You can also use these commands from GRUB's Command Line Interface (CLI)  while you are booting up to try out all the colors you like and see what they look like. Just press 'c' from your GRUB menu for a command line and use the same commands to change the colors as you please, then press 'Esc' to go back to your GRUB menu to see how it looks. You can do that as many times as you like until you have a combination you are happy with.

viewport
If you have a nice splashimage but the rectangle in the GRUB menu that the operating system titles are printed in happens to be in the way of an important part of the picture, you can either make a new splashimage with the subject of the picture in a different spot, or you can move that rectangle.
The rectangle can be moved around somewhat and made larger or smaller too.

GRUB's viewport command is for controlling the position and size of the rectangle that the text fits inside in the GRUB Menu when we use a splashimage. (only available in Graphics mode