GRUB Page

Edited Saturday, May 10 2008

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


PAGE INDEX
   Trouble Shooting Section:   Common Booting Errors and Some Possible Cures  

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

Graphical User Interface. - the GRUB menu that you see at boot time.

GRUB's Command Line Interface. - GRUB is almost a miniature operating system in it's own right.

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. - personalize your GRUB by editing your /boot/grub/menu.lst file.


Editing GRUB's device.map (SATA and PATA drives together) -tell GRUB which is the first disk.

menu.lst example file with links. the links explain what to do with most of the commands.

Edit /usr/sbin/update-grub. makes your operating system title persistent over kernel updates.


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.

How to back up and restore your MBR. - dd command.

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

How to get GRUB's Command Line to investigate a computer. Use tab completion, find and cat .

Direct (kernel) Boot. Boot Ubuntu and most Linux systems directly by their kernel and initrd.img

Configfile Boot. Boot Ubuntu and most Linux systems by their configuration file

Chainloader Boot. Boot Ubuntu and most Linux systems by their partition (boot sector).

Chainloading Windows the simple way,  for a single hard disk install,

Chainloading Windows using map commands when it is installed on a non-first hard disk

GRUB and MultiWindows  How to hide one Windows install from others on the same disk



Editing GRUB's menu.lst file

1) default. - set which O.S. will be booted automatically by the timer if no-one presses a key

2) splashimage.  - make your GRUB menu beautiful! Full instructions!

3) fg + bg colors.- set the color of your highlight bar and the text color to suit your splash image.

4) timeout. -you can set the number of seconds for the countdown timer.

5) color. - have your menu show up in color, choose your own color scheme.

5) hiddenmenu. - show or hide your GRUB menu on boot-up.

6) password. -lock your GRUB settings so no-one else can make changes.


DEBIAN AUTOMAGIC KERNELS LIST.- this area is read by the update-grub script.
Edits in this area make changes persistent over a kernel update.
Only for use by the operating system, don't put foreign operating system entries in this are or they will be automagically deleted.

kopt= (kernel options) - if you set special kernel options, make the persistent here.

crashdump=

groot= (grub root device) - if you changed the partition number, make it persistent here.

alternative=

lockalternative=

defoptions


altoptions

lockold=false

xenhopt=

altoptions=

howmany=- set the number of kernels you want displayed in your GRUB menu.

memtest86=. - makes the memory test in the GRUB menu persistent over a kernel update.

updatedefaultentry=
. - preserves the default entry you set over a kernel update.


8) Operating System Entries. - these are the commands for booting the operating systems.

9) Operating System Entries for Multiple Booting More Linux Systems

10) Quick Guide to GRUB's Numbering System. - list of /dev/hda1 is equivalent to (hd0,0), etc.

11) Hide titles in the GRUB Menu.- tidy up, comment out extra entries you'll never use.

12) Add your system's hostname to the GRUB Menu. - customize and personalize your menu.




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.





 Ubuntu, kernel 2.6.20-15-generic                        
 Ubuntu, kernel 2.6.20-15-generic (recovery mode)
 Ubuntu, 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.


fig 1 GRUB  
The GRUB Menu is the 'GUI' (Graphical User Interface) that we normally expect to see each time we boot our computers. The grub menu is simple to use, even for beginners.

All that is normally necessary for most people to do is wait for your favorite operating system to boot after a set number of seconds.
If you want you can or press any key to stop the count-down timer while you think it over and make a decision.
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.
Most of the time those are the only things you need to know how to do to be able to boot with GRUB.
 
As the sign says though, if you're having booting problems you can always press your 'e' or your 'c' key.

If you press your 'c' key, you get  GRUB's Command Line Interface.

Your 'e' key will allow you to Temporarily Edit the GRUB Menu.





GRUB, (GRand Unified Bootloader), is much more than just an ordinary boot loader.
 
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) You will normally be booting from GRUB's  Graphical User Interface .
There are a lot of options available in GRUB to help you if you ever have trouble booting.
You can use  GRUB's Command Line Interface (CLI),
or you can Temporarily Edit the GRUB Menu 'on the fly' 
You can work in a GRUB shell in a terminal in a LiveCD or when another installed OS is booted.  

4) When GRUB installs itself it can detect all operating systems in your computer and correctly configure itself automatically most times.
Occasionally it needs a small correction to an operating system's entry in the menu.lst file, but not very often.  When IDE and SCSI (SATA) drives are used together it can mean some manual adjustments will need to be made.
Other boot loaders need to be  set up manually every time.

5) 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 will show you how to find that and some of the things you can do with it further down this page.



Orientation 

Here's where to find some important files to do with booting.
First we'll see how to find the our way around the file system a little in 'GUI' mode in case there are some new people with us fresh from Windows, then we'll find it in 'terminal', and open it with our text editor.

To start this tour, you go 'Places'-->'Home Folder', and then look for the 'Up' arrow and go up 'two floors', to the top of our directory tree.
This our 'root directory', it's the big main directory (folder) that contains all the rest of them.
Very often the root directory is written as: /  (a slash), for short, instead of typing out the words.
                                   
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 map or miniature model of the file system 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 scriptps needed for booting including /etc/rc scripts.
Here are two links about init, Replacing init with Upstart - linux.com, 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.

The stage1 file is a copy of the one that gets installed in the MBR.
This one is 512 bytes in size, as big as one sector of a hard disk. I don't know why it's 512 bytes instead of less than 446 bytes. The bootloader has to fit in less than 446 bytes of the MBR. There are a few other little bits and peices of code  that GRUB has to share the 446 byte part of the MBR with too.
GRUB's stage1 can also be copied to a boot sector, but in that case the stage1_5 doesn't go with it.

There are six of the stage1_5 files to choose from, those are the files that GRUB installs to the first fifteen sectors of the first track of the hard disk, right after the MBR.

GRUB's stage2 file is there, that's 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.

The bootstrap mechanism used in GRUB.
  
The /boot/grub/menu.lst file is the most interesting one to most of us. That'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 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.

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 Page........................................................................Super GRUB Disk Page








Customizing your GRUB Menu  

Customizing the GRUB menu is great fun and you can begin to learn a little about computer programming this way.

Tomosaur's GUI GRUB editing script
If want to edit GRUB's menu.lst the easy way, many of the same results can be achieved with Tomosaur's GUI GRUB editing script if you would prefer to use that method. 
SCRIPT: GrubED - GUI Grub editing  ( 1 2 3 ... Last Page)
 
Meanwhile, for the rest of us, here's what a typical /boot/grub/menu.lst file looks like.
This one is special because I made the commands into hyperlinks that you can click on to take you to an
explanation about each one.

# 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

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

## 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

## 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

## Setup crashdump menu entries
## e.g. crashdump=1
# crashdump=0

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,1)

## 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
root        (hd0,1)
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)
root        (hd0,1)
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+
root        (hd0,1)
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
7 grub
This is an entire GRUB menu.lst file out of one of my computers.  It should be fairly typical for a dual boot computer with one hard disk. 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.





Changing the default (operating system 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.


Add a splashimage to the GRUB menu
# array will desync and will not let you boot your system.
default        0

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

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 trust this site, you are welcome to download any splashimages you like from here. 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).
If you don't trust me, or you just want to make your own too, for fun, I have help on how to do that further down this page. Link:
Making your own splashimage

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

EurekaFlagthumbnail AboriginalFlag
billo2g1sThumb.png
EurekaFlag.xpm.gz
Download
The Australian 'rebel' flag, from the miner's strike at Eureka Stockade in 1854.
AboriginalFlag.xpm.gz
Download
billos2g1s.xpm.gz
Download
Made from a photo of a genuine Australian Aboriginal dot painting by artist 'Billo' Wallace.

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 coping, 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 and digital art works that look great beforehand will look horrible after they are converted into GRUB splashes. A few actually look better. Expect a lot of rejects. You will need to use patience, luck and good judgment until you learn how to choose images that can be turned into good GRUBsplashes.

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.

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.

Color Codes: http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html

Web Diner's hex code color chart: http://www.webdiner.com/annexe/hexcode/hexcode.htm




For example these can be applied something like this,
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).

for example,
viewport 0 0 66 16
gives a small rectangle in the upper left of the screen.

for example,
viewport 3 3 80 30
means you will have the largest rectangle in the middle of the screen

for example,
viewport 11 6 80 30
gives you a large rectangle in the lower right of the screen

I couldn't get it to accept any numbers for a small rectangle in the lower right though, sorry. You may be able to experiment at the command line like I did until you get the results you want.

The syntax for viewport is like this,
viewport x0   y0   x1    y1

The numbers seem to range between,
viewport  0-11  0-6 66-80 16-30

x0 sets the left-right positioning for the left side of the rectangle.
In my tests the smallest number I could set for this parameter was 0 and the largest was 11,
although sometimes a number less than 11 had to be settled for, depending on the other parameters.

y0 sets the up and down position for the rectangle.
0 entered here makes the rectangle appear as close as possible to the top of the monitor.
The number 6 was the largest number I could get it to accept, which made the rectangle lower.

x1 can be in the range from 66-80 and sets the width of the rectangle.

y1 can be a number in the range between 16 and 30 and sets the height for the rectangle.

This command can also be run from GRUB's Command Line Interface to experiment with it until you get your viewport right for
your splashimage.
After that you can add it to your /boot/grub/menu.lst somewhere around your splashimage command.

You should experiment with these commands at GRUB's Command Line Interface (CLI)  while you are booting up to try out all the parameters until you get the viewport how you like it before adding it to your menu.lst file.
Just press 'c' from your GRUB menu for a command line and use the viewport command to change the rectangle 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.




Setting the timer
for the boot loader is the next subject.
default        0

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

## 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 that.

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 Page.................................................................Super GRUB Disk 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
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 with colors, instead of just plain old black and white.

The colors cyan/blue white/blue the given defaults. 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 paste in your own color combinations. Some of the color combinations I tried are listed below.
 
command          font&border/panel         hilited font/rectangle
color                 black/brown                  yellow/black
color                 black/green                   yellow/black
color                 black/magenta              white/red
color                 white/red                       light-gray/black
color                 light-gray/blue              black/light-gray
          
Here's the for a full list of the colors you can try, in the GNU GRUB manual, Click Here.

You can also cause the GRUB menu to have a blinking foreground color by inserting 'blink-' before the foreground color, for example,

color           black/brown                       blink-yellow/black
color           blink-white/red                  light-gray/black

An easy way to experiment with the different color combinations for your GRUB menu, instead of editing your menu.lst file and rebooting every time, is to use GRUB's Command Line.
Press 'c' from the GRUB menu when your computer is booting to get a GRUB Command Line.
Type the word color as a command, followed by some colors you want to try. For example,
Code:
grub>  color white/red light-grey/black
Then press 'Enter', then press 'Esc' to see what your GRUB menu will look like with those colors. Press 'c' again and try some different colors, and so on until you decide on the colors you want. Then boot and edit your /boot/grub/menu.lst with your chosen colors. GRUB Command Line.

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


Set a GRUB password
# Pretty colours
#color cyan/blue white/blue

## 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


fig 13 GRUB
I recommend the following information from the 'Dapper Guide' for how to set your GRUB password. Click on the following link please, 15.2 How to disable all interactive editing control for GRUB menu
Here is a link to the Feisty Starter Guide too, 1.19.2 How to disable all interactive editing control for GRUB menu


DEBIAN AUTOMAGIC KERNELS LIST
#
# 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

This part of GRUB's menu/lst file doesn't really do anything. Everything here is a comment.
It's just to show you a couple of examples of how an operating system entry should look.

The line at the bottom of this table is to let people know that they should put operating system entries that are 'static' (in other words, ones that are not to be automagically updated), either above the start of the automagic kernels list or after it, but not in it.
You can paste your Windows entry here if you want Windows to be first in the list and boot by default.
Your Windows entry to be automagically deleted every time Ubuntu is updated with a new kernel if you paste it anywhere between the beginning and the end of the debian automagic kernels list. (Well, it shouldn't have been there in the first place). Many users don't understand that and blame GRUB or Ubuntu for their problems.

### 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


This line marks the beginning of the Automagic kernels list
The bottom of the automagic kernels list is marked with a line that looks like the following,
### END DEBIAN AUTOMAGIC KERNELS LIST

The idea of the Debian Automagic kernels list is to allow us to have a new kernel installed as part of an update from the Internet. When we do that, our menu.lst file is updated 'automagically' with the correct details for booting our new kernel. We don't have to edit the file manually each time. It's a wonderful feature!
The debian 'update-grub' script is the program that controls that, but there are a few user
configurable choices we can modify if we need to by editing our menu.lst file. It is relatively rare for anyone to need to modify these, but we'll go through some of them just below here anyway. Stay tuned...

I should also mention here, while we are on the subject, that 'update-grub' can also be run from our terminal, voluntarily, if the occasion requires it. For example, your whole menu.lst file can be completely deleted. Running 'sudo update-grub' in a terminal can generate a brand new one for you! Now isn't that magic?
You might need to edit it with any other operating system entries yourself though.

From here on, inside the automagic kernels list, double hashes (##) are used for preceding lines that are only 'comments', (lines that are there for humans to read and for the computer to ignore).
Lines that affect the computer will have single hashes (#), these are not to be removed. This is very important. Other wise 'update-grub' won't work properly for you.

Okay, now we'll look at a few settings the user can edit for update-grub in the automagic kernels list here,
## ## 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
kopt stands for 'kernel options'.
These kernel options will be applied to all kernels in your
menu.lst
'root='This line should point to your linux partition. This line controls what is entered automagically in your new operating system entry 'kernel /vmlinuz root=UUID=...' when you receive a kernel update.
'ro' means the file system will start off as 'read only', just for the first part of booting.

If you require additional kernel parameters (for example, if someone has asked you to test booting with certain parameters in order to troubleshoot a problem), add them to the end of the line, for example to add 'noapic', 
Code: