Logo.png
GRUB2 Configuration
Edited Saturday, August 21 2010  Document made with KompoZer

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

GNU GRUB is a work in progress and the information in this website is incomplete and may be wrong and/or out of date. Please consult the official GNU GRUB 1.98-r2692 manual.

The information in this page is current for GNU GRUB version 1.98~1ubuntu7 in Ubuntu Lucid Lynx.

Page Index
About grub.cfg

Four Ways to Edit your grub.cfg

Editing /etc/default/grub

Editing /etc/grub.d/05_debian_theme

Custom Boot Entries




grub.cfg

To view your /boot/grub/grub/cfg file, you might use the following command,
cat /boot/grub/grub.cfg
Press your up or down arrow keys to scroll up and down the file, use your 'q' key to quit and return to your regular terminal prompt.

As the name suggests, grub.cfg is GNU GRUB's main configuration file. Changes to this file affect the appearance of our GRUB Menu, see GRUB2 Menu Mode, and also the way the operating system(s) in computer will boot.

We're not supposed to edit this file directly, as the sign at the top says.
Instead, this file will be built automatically for us by another program, and that program is called grub-mkconfig, probably that's short for grub make configuration file, and that's what it does.

The grub-mkconfig program runs other scripts and programs such as grub-mkdevice.map and grub-probe and then generates a new grub.cfg file. It also reads files in /etc/default/grub and the /etc/grub.d/debian theme file to tell it what to do. Those are the files we can edit or create for ourselves to change our GRUB settings. I'll show you more about that later.

Below here is an example of a grub.cfg for a new Ubuntu installation in a computer that already has one other Ubuntu installation dual booting with Windows XP.
I have highlighted the commented lines in yellow to draw your attention to them.
You should notice that they each mark the beginning and ending of their own section of the grub.cfg and they appear in numerical sequence starting from the /etc/grub.d/00_header at the top.
The last section of this file is the /etc/grub.d/40_custom area at the bottom of the grub.cfg file.
Each of these sections of the grub.cfg file are controlled by the scripts with the same names, and those are the ones we edit to make changes to our grub.cfg.
The changes will come into effect right after we run 'sudo grub-mkconfig -o /boot/grub/grub.cfg' to write the new grub.cfg file.

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  set saved_entry=${prev_saved_entry}
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z ${boot_once} ]; then
    saved_entry=${chosen}
    save_env saved_entry
  fi
}

function recordfail {
  set recordfail=1
  if [ -n ${have_grubenv} ]; then if [ -z ${boot_once} ]; then save_env recordfail; fi; fi
}
insmod ext2
set root='(hd1,6)'
search --no-floppy --fs-uuid --set 6655ee5e-45d1-4d1c-9a7d-10f30f16e745
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
insmod ext2
set root='(hd1,6)'
search --no-floppy --fs-uuid --set 6655ee5e-45d1-4d1c-9a7d-10f30f16e745
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
if [ ${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-24-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd1,6)'
    search --no-floppy --fs-uuid --set 6655ee5e-45d1-4d1c-9a7d-10f30f16e745
    linux    /boot/vmlinuz-2.6.32-24-generic root=UUID=6655ee5e-45d1-4d1c-9a7d-10f30f16e745 ro   quiet splash
    initrd    /boot/initrd.img-2.6.32-24-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-24-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd1,6)'
    search --no-floppy --fs-uuid --set 6655ee5e-45d1-4d1c-9a7d-10f30f16e745
    echo    'Loading Linux 2.6.32-24-generic ...'
    linux    /boot/vmlinuz-2.6.32-24-generic root=UUID=6655ee5e-45d1-4d1c-9a7d-10f30f16e745 ro single
    echo    'Loading initial ramdisk ...'
    initrd    /boot/initrd.img-2.6.32-24-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
    insmod ext2
    set root='(hd1,6)'
    search --no-floppy --fs-uuid --set 6655ee5e-45d1-4d1c-9a7d-10f30f16e745
    linux16    /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
    insmod ext2
    set root='(hd1,6)'
    search --no-floppy --fs-uuid --set 6655ee5e-45d1-4d1c-9a7d-10f30f16e745
    linux16    /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Home Edition (on /dev/sda1)" {
    insmod fat
    set root='(hd0,1)'
    search --no-floppy --fs-uuid --set 2629-16f0
    drivemap -s (hd0) ${root}
    chainloader +1
}
menuentry "Ubuntu, with Linux 2.6.32-24-generic (on /dev/sdb1)" {
    insmod ext2
    set root='(hd1,1)'
    search --no-floppy --fs-uuid --set 2e0ae64a-7104-4545-b405-5633fdad70bd
    linux /boot/vmlinuz-2.6.32-24-generic root=UUID=2e0ae64a-7104-4545-b405-5633fdad70bd ro quiet splash
    initrd /boot/initrd.img-2.6.32-24-generic
}
menuentry "Ubuntu, with Linux 2.6.32-24-generic (recovery mode) (on /dev/sdb1)" {
    insmod ext2
    set root='(hd1,1)'
    search --no-floppy --fs-uuid --set 2e0ae64a-7104-4545-b405-5633fdad70bd
    linux /boot/vmlinuz-2.6.32-24-generic root=UUID=2e0ae64a-7104-4545-b405-5633fdad70bd ro single
    initrd /boot/initrd.img-2.6.32-24-generic
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###


   


Four Ways to Edit your grub.cfg

1. Normal circumstances,
The easiest way to make changes to this file is to simply run sudo grub -mkconfig -o /boot/grub/grub.cfg  to make a new grub.cfg file. We would want to do this after adding or removing operating systems to or from our computer. That command will run grub-mkconfig to scan your computer and update your grub.cfg file with boot entries for all of the operating systems you have in all of the discs you have plugged into your computer at that time. A list of boot entries for all of your bootable kernels in each operating system will be added to your grub.cfg.

2. Special customization
If you want to customize your /boot/grub/grub.cfg file yourself, you first need to edit /etc/default/grub and/or one of the files in /etc/grub.d and then run 'sudo grub-mkconfig'.
The 'sudo update-grub' or 'sudo grub-mkconfig' scripts will read /etc/default/grub and the files in /etc/grub.d in numerical sequence and update your /boot/grub/grub.cfg file with your changes. More on this subject will come up further down this page.

3. By another script or program
Another way to have this file edited for us will be to use scripts and programs that are currently still under development by members of the Ubuntu community. One that I have tried is called 'SUM', short for 'Start Up Manager', and it does support GRUB 2 but last time I tried it was still in the early stages of development for GRUB 2 and it didn't have very many functions enabled yet.  Here's a link for more info about that, StartUpManager - Ubuntu Community Docs

4. Direct editing
If you have your GRUB 2 in a 'Dedicated GRUB 2 Partition', it's not necessarily under the control of the operating system but it is still possible to run sudo grub-mkconfig with the path to the mounted partition.
Some people still want to do things manually though, so what some people do is chmod their /boot/grub/grub.cfg to relax the file permissions on it so they can edit it manually and directly.
In this way it's possible to give our boot entires user freindly titles instead of just kernel numbers.
See How To Make a Dedicated GRUB 2 Partition - with an editable grub.cfg
Or How To Make a GRUB 2 USB Disk - with an editable grub.cfg



Editing /etc/default/grub

You can open /etc/default/grub file with the following command,
gksudo gedit /etc/default/grub

This is what it should look like,
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#
GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
# GRUB_INIT_TUNE="480 440 1"


GRUB_DEFAULT=
0
The number at the end of this line can be changed to make the highlight bar or selection bar in the GRUB Menu appear automatically on any GRUB Menu entry we like.
0 (zero) tells GRUB we want the first or top GRUB entry automatically selected unless we over ride that selection with our up or down arrow key during boot-up.
Any number greater than 0 (zero) will mean boot entries further down the GRUB Menu will be selected instead.

Alternatively, replace the number here with the word 'saved' to enable the grub-set-default command to work.
See this thread, [ubuntu] How do I change boot order in 9.10? - Ubuntu Web Forums, especially post  #14 by drs305,
code:
sudo grub-set-default X

TIP: Knowing how to change this setting might be useful when you want to have a particular operating system booted automatically when the computer is unattended.
For example, my ISP allows me a bandwidth of 40 GB per month during the 'off peak' hours between 01:00 and 09:00 hrs. I'm allowed another 40GB per month of bandwidth allowance for the 'peak' time period each day, which is most of the day, between 09:00 and 01:00.
I want to turn my computer off to save energy when I go to sleep, but I also want to share the latest Ubuntu .iso file I have downloaded in my computer  using bittorrent.
To optimize the use of my bandwidth allowance, I want to share the file during the 'off peak' hours.
I will set my computer's BIOS to start the computer at 01:00.
There are several programs in Ubuntu that can start another program up at a preset time. Alarm Clock is one, Evolution Calendar is another and there's also the more traditional crontab. I can use any of those to run /usr/bin/transmission (start bittorrent) shortly after the time the computer is set to boot itself up. First of all though, I need the operating system containing the .iso file to be selected by default. If it doesn't happen to be the one that is first on the boot menu, I can easily to use grub-set-default to set GRUB to make sure it is selected.


#GRUB_HIDDEN_TIMEOUT=0
Deleting the # mark will hide the GRUB Menu.
If you only have one operating system in the computer you might not need to see the menu, and you may want the timer left on 0 seconds for fast booting.
Sometimes people install Ubuntu in a computer they share with others who would be frightened and confused if they saw a GRUB Menu. If that's the case you can install Ubuntu and delete this hash mark to hide the GRUB Menu. I
f you set the timer to 3 seconds or so then others won't see the GRUB Menu so it won't annoy them.
The computer will still boot quickly enough, but if you press the shift key within the three second time limit you can bring up your GRUB Menu and boot Ubuntu.

GRUB_HIDDEN_TIMEOUT_QUIET=true
When the menu is hidden, this hides the timer as well. Set it to false if you do want to display the timer.


GRUB_TIMEOUT="
10"
This number sets the number of seconds we want GRUB to wait before automatically booting the default boot entry, unless any key is pressed to cancel the count-down timer.
  • We can change this number to a smaller number of seconds if we want our computer to boot a little faster.
  • We can set this number to a higher number of seconds if we want more time to hit a key or decide what operating system we might want to boot.
  • We can change this number to  -1  if we want to keep the countdown timer on hold and have GRUB wait forever or until we come back and tell GRUB what we want to do.


GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`

 !!! This line is not to be edited at all. If this line is edtied it will cause update-grub or grub-mkconfig to fail and display an error message about not being able to find whatever the name is the user put there. !!!


GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
This line is for our standard kernel options and should be left as it is.


GRUB_CMDLINE_LINUX="
vga=795"
This is the place where we can insert any extra kernel options we may need.
Example Thread: [SOLVED] Ubuntu 9.10 And grub issue..... need help please.
Source: TWEAKING GRUB 2 - Dr.Lock
See also: Common Boot Options - Ubuntu Community Docs, and Kernel Parameters, www.kernel.org

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
I'm not sure about this line yet. Sorry.


# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=
640x480
You can set a different resolution here, if you do so the font will appear smaller in your GRUB Menu and in your GRUB CLI mode, which may be a good thing because then you'll be able to see more of it.
If you have a splashimage, you'll be able to set a larger one if you set a higher resolution for GRUB, which usually means it will look even nicer. See
How To Change Boot Menu Resolution for more information.

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
The comment above this line is sufficient to explain it.

# Uncomment to disable generation of recovery mode menu entrys
#GRUB_DISABLE_LINUX_RECOVERY="true"
#
The comment above this line is sufficient to explain it.




Editing /etc/grub.d/05_debian_theme

You may open your /etc/grub.d/05_debian_theme with a command like the following,
gksudo gedit /etc/grub.d/05_debian_theme

Here's what you can expect it to look like,
#!/bin/bash -e

source /usr/lib/grub/grub-mkconfig_lib

# this allows desktop-base to override our settings
f=/usr/share/desktop-base/grub_background.sh
if test -e ${f} ; then
  source ${f}
else
  WALLPAPER="/usr/share/images/desktop-base/moreblue-orbit-grub.png"
  COLOR_NORMAL="black/black"
  COLOR_HIGHLIGHT="magenta/black"

fi

set_mono_theme()
{
  cat << EOF
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray

EOF
}

# check for usable backgrounds
use_bg=false
if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] ; then
  for i in /boot/grub/`basename ${WALLPAPER}` ${WALLPAPER} ; do
    if is_path_readable_by_grub $i ; then
      bg=$i
      case ${bg} in
        *.png)        reader=png ;;
        *.tga)        reader=tga ;;
        *.jpg|*.jpeg)    reader=jpeg ;;
      esac
      if test -e /boot/grub/${reader}.mod ; then
        echo "Found background image: `basename ${bg}`" >&2
        use_bg=true
        break
      fi
    fi
  done
fi

# set the background if possible
if ${use_bg} ; then
  prepare_grub_to_access_device `${grub_probe} --target=device ${bg}`
  cat << EOF
insmod ${reader}
if background_image `make_system_path_relative_to_its_root ${bg}` ; then
  set color_normal=${COLOR_NORMAL}
  set color_highlight=${COLOR_HIGHLIGHT}
else
EOF
fi

# otherwise, set a monochromatic theme for Ubuntu
if ${use_bg} ; then
  set_mono_theme | sed -e "s/^/  /g"
  echo "fi"
else
  set_mono_theme
fi
This is the /etc/grub.d/05_debian theme file.

You may edit this file and then run 'sudo grub-mkconfig -o /boot/grub/grub.cfg' to have the changes written persistantly to your /boot/grub/grub.cfg file.


  WALLPAPER="/usr/share/images/desktop-base/moreblue-orbit-grub.png"
If you have a background image, you can specify it here.
See GRUB2 Splashimages - How to make your GRUB Menu look beautiful



  COLOR_NORMAL=black/black

  COLOR_HIGHLIGHT=magenta/black
If you specified a background image and GRUB 2 can display it, GRUB 2 will make your menu and font colors according to what is specified in the next two lines.
You can specify any combintion of  black (or transparent), dark-gray, light-gray, white, brown, yellow, red, light-red, blue, light-blue, green, light-green, cyan, light-cyan,   magenta, light-magenta.
See GRUB2 Splashimages for more information.

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


set_mono_theme()
{
  cat << EOF
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
EOF
}

Not everybody cares about having a fancy background image. Very often just a colored menu can look just as nice, and is a little more practical since it's easier to read your text against a monocolored screen.
For a colored GRUB Menu just specify here any combintion of  black (or transparent), dark-gray, light-gray, white, brown, yellow, red, light-red, blue, light-blue, green, light-green, cyan, light-cyan,   magenta, light-magenta. If you don't then your GRUB Menu will just remain black and white.



Custom Boot Entries

You may want to add your own customized boot entries when,
  • your GRUB menu is too long to scroll down because you have a long list of kernel updates
  • you have a lot of operating systems and they all have a lot of updated kernels too
  • if you want to give your operating systems freindly names
  • you want control over the sequence your operatings systems appear in the list
  • os-prober fails to detect your operating system and add it to the list automatically
To make a custom boot entry, we need to create a new file in /etc/grub.d/ with a text editor like gedit or nano.
The file name needs to begin with a two digits number followed by an underscore.
The numbers at the start of the file name determine where your entries will appear in your grub menu.

Numbers we can't use are numbers already occupied by existing scripts.
Existing scripts in /etc/grub.d include
  • 00_header
  • 05_debian_theme
  • 10_linux
  • 20_memtest
  • 30_os-prober
  • 40_custom
Obviously, as the name implies, 40_custom is really the proper script for custom boot entries. The problem with that is, if we already have a long list of operating systems, each with a long list of entries from a lot of kernel updates, the custom entries will be about half a mile down the window, and it'll take us an hour to scroll there.

Therefore we have no choice but to make our selves a new custom  boot entry file with a number greater than 05 but less than 10 preceding its name. That will cause our script to be read between 05_debian theme and 10_linux, meaning our custom boot entries will be at the top of our GRUB Menus.
example,
gksudo gedit /etc/grub.d/06_custom
This will open a new empty (blank) file and name it '06_custom'. When we click 'save' it will save the file to /etc/grub.d/ directory.

Several types of boot entries are popular.
These include,Examples of different kinds of boot entries are shown below


The symlink boot entry
#! /bin/sh -e
echo "Adding custom boot entry(s)" >&2
 cat << EOF
menuentry "Ubuntu Hardy Heron Symlink Boot" {
    linux    (hd1,1)/vmlinuz root=UUID=2ddc16ca-61f5-4fe4-a16e-4b4bf75d86ff ro quiet splash
    initrd    (hd1,1)/initrd.img
}

EOF

The symlink boot entry is almost like a direct kernel boot entry except the path and the exact file name for the linux kernel and initrd.img are omitted and replaced with the filename of the symlinks in the root of the file system. Symlinks are like shortcuts, and these symlinks point to the most recent kernel and initrd.img files. The symlink boot entry is very reliable.
See Orientation - GRUB Legacy Page.
Link: see post #24 by phenest in the following thread, GRUB 2 Testing Question - Ubuntu Web Forums. Tested and worked for me when I tried it

TIP:
A handy trick to remember all your file system UUID numbers is to copy the output from the 'sudo blkid' command and paste it to the file you're editing. I just leave mine there for future reference, but I make sure I hash them out first. Notes can be typed after them too.


The chainloader type of boot entry
#! /bin/sh -e
echo "Adding custom boot entry(s)" >&2
 cat << EOF
menuentry "Chainload Windows 7" {
    set root=(hd0,1)
    chainloader +1   
}

EOF


The chainloader type of boot entry is also very popular.
We can boot another boot loader via a MBR or a Boot Sector.
In order for this to work, there needs to be some code written either in the MBR of the hard disk you want to boot or in the boot sector of the partition that points to an existing boot loader.
From there, the other boot loader will take over the booting process.
The chainloader boot entry is the second most reliable, and extremely versatile.
Tested and worked for me when I tried it

If you're trying to chainload a partition boot sector, you might need to use the -f option, which tells GRUB to ignore the fact that there might not be a bootable disc signature there, (!= 0xaa55). I'm not sure about exactly when that's needed or isn't needed yet. It seems to be only needed in CLI Mode GRUB.


The configfile boot entry.
#! /bin/sh -e
echo "Adding custom boot entry(s)" >&2
 cat << EOF
menuentry "Configfile Boot on Hardy Heron in /dev/sdb1" {
        configfile (hd1,1)/boot/grub/grub.cfg

}
EOF


With the configfile type of boot entry, we're limited to another distro with the same GRUB as we're using. It will be our own GRUB that does the booting, but it will take commands from the grub.cfg file we direct it to load. We can't use the configfile command on any other boot loader because the commands will all be like a foreign language to GRUB. I don't think we can use the configfile for Legacy GRUB's menu.lst file either, the commands have all changed.
The configfile command works beautifully well between two operating systems that both use GRUB 2, I like it. Tested and worked for me when I tried it

The configfile command can be a lot of fun, there are all kinds of inventive ways to use it.

TIP:
We can also use the configfile command to direct GRUB to load another text file in our own file system, perhaps with our own customized boot entries in it. That would be another alternative way to organize our custom boot entries. It would also be a fun way to play with GRUB2. We could use the second grub.cfg for all kinds of experiments. It would need to be named something slightly different or located in a different directory to avoid overwriting our real grub.cfg file. The 'sudo grub-mkconfig' command can make grub.cfg files with the -o option with any path and file name we tell it to. See grub -mkconfig.


How To Add Custom Boot Entry and Boot an .iso File in the Hard Disk
#! /bin/sh -e
echo "Adding custom boot entry(s)" >&2
 cat << EOF
menuentry "Ubuntu Lucid Lynx ISO" {
loopback loop (hd0,1)/home/herman/Downloads/lucid-desktop-i386.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/home/herman/Downloads/lucid-desktop-i386.iso noprompt noeject quiet splash
initrd (loop)/casper/initrd.lz
}
EOF
Loopback Boot Entry
A new kind of boot entry is the loopback boot entry for booting live CD .iso files.
This custom boot entry will boot my new Ubuntu Lucid Lynx Alpha1 .iso file, which remains in my Downloads directory where I can continue sharing it with bittorrent.
My Ubuntu Karmic Koala installation is in an SSD drive which I often remove from my computer and pop into a USB external case and carry around with me. Wherever I go I can plug the USB SSD external into a computer and boot my Ubuntu Karmic Koala installation.
With the .iso boot entry that this script adds to my Karmic Koala GRUB2 Menu, I now have the opportunity to boot the Lucid Lynx .iso file instead, and run it as a Live CD from inside my USB SSD drive. 
The last time I tried I could not use an .iso file booted in this way for this for installing Ubuntu with.
See also this website's loopback (command, CLI Mode).

Here are links to two web pages giving examples of how to use the loopback command to boot .iso files containing a bootable Linux CD image when the bootable .iso is located in a hard drive,  
Boot an ISO via Grub2 - Mika's Blog

MultiBoot USB with Grub2 (boot directly from iso files) - panticz , (thanks to pxwpxw for the link).

TIP: If you need to make a long line of kernel options as may be required for the .iso files of some live CDs, be sure to click 'Edit'-->'Preference' in your Gedit text editor and disable 'text wrapping', otherwise you may encounter  lot of difficulties.
Tested and worked for me when I tried it


When you are finished putting all of your custom boot entries in your /etc/grub.d/06_custom file, it needs to be chmodded to make it executable,
sudo chmod 755 /etc/grub.d/06_custom
Use a command something like this to change the file permissions to make your file executable.

Finally, don't forget to run either the 'sudo update-grub' or 'sudo grub-mkconfig' command.
sudo grub-mkconfig -o /boot/grub/grub.cfg

Now you can reboot and see if it works. Good luck :)




### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
    linux    (hd0,2)/boot/memtest86+.bin
}
### END /etc/grub.d/20_memtest86+ ###

See: memtest86+ - this website's GRUB Legacy Page



### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

This section of the grub.cfg is under the control of our /etc/grub.d/30_os-prober and probably will not need any interferance from users.
All of our other operating systems should be automatically detected and appear in this section of our /boot/grub/grub.cfg files.
If not, check to make sure the disk is plugged in and working. If so, possibly you will need to make a custom entry for the operating systems that aren't being added automatically.


Custom Boot Entries
For this section of the grub.cfg, we have 31_<filename> to 39_<filename> open to us as possibilties for custom boot entries which we may want to have appearing at the bottom of our GRUB Menus, below all of our other operating system entries.

There is also /etc/grub.d/40_custom which is our designated custom boot entry file.

After that, we have 41_<filename> and greater open to us as possibilties for custom boot entries which we may want to have appearing right at the bottom of our menu.lst files.

See Custom Boot Entries for more information.