Computer And Technologies

Computer And Technologies: How to edit Grub loader?

Thursday, 28 May 2009

How to edit Grub loader?


GNU GRUB ("GRUB" for short) is a boot loader package from the GNU Project. GRUB is the reference implementation of the Multiboot Specification, which allows a user to have several different operating systems on their computer at once, and to choose which one to run when the computer starts. GRUB can be used to select from different kernel images available on a particular operating system's partitions, as well as to pass boot-time parameters to such kernels.

GRUB is dynamically configurable; it loads its configuration at startup, allowing boot-time changes such as selecting different kernels or initial RAM disks. To this end, GRUB provides a simple, bash-like, command line interface which lets users write new boot sequences.

GRUB is highly portable. It supports multiple executable formats, and is geometry translation independent; while Multiboot compliant, it supports non-multiboot operating systems such as Microsoft Windows and OS/2 via a chain loading function. GRUB supports all commonly used Unix file systems as well as VFAT and NTFS as used by Windows, and supports Logical Block Address (LBA) mode. GRUB allows users to view the contents of files on any supported file system.

GRUB can be used with a variety of different user interfaces. Most Linux distributions take advantage of GRUB's support for a graphical interface to provide a customized boot menu with a background image, and occasionally mouse support.[citation needed] GRUB's text interface can be set to use a serial link to provide a remote terminal boot loader access.

GRUB can download operating system images from a network, and can thus support disk-free systems. GRUB supports automatic decompression of OS images prior to booting from them.

GRUB differs from other boot loaders by being able to communicate with a user directly via a GRUB prompt. A GRUB prompt is the stage before GRUB loads an operating system and can be triggered at a text-mode GRUB booting screen (which is controlled by the configuration file "menu.lst" (or "grub.conf": see below)) by pressing the "c" key. A GRUB prompt (similar to bash) can also be obtained by booting GRUB as a stand alone system without an operating system attached or in any GRUB installation with an operating system when the "menu.lst" file is absent. From the GRUB prompt a user can manually select and control booting from any installed operating system by using bash-like commands. To boot an operating system automatically, the appropriate commands are placed in a configuration file called "menu.lst" in a designated subdirectory.

GRUB has a rich set of terminal commands that allow a user at the GRUB prompt to view the partition details of the hard disks, alter a partition setting, re-map the disk order temporarily, boot any user-defined configuration file and to view booting configuration of other boot loaders in file formats GRUB supports. Thus, without prior knowledge of what is installed on a computer one can use GRUB from an external device such as a floppy disk, USB device or a CD-ROM to boot up an installed operating system.

GRUB uses a scrolling screen for selection of operating systems to boot. This means 150 or more booting choices can be controlled by GRUB with ease by adding each to the "menu.lst" configuration file, and selecting one at boot time using the arrow keys.

One boot loader can boot another boot loader by chainloading. GRUB uses the same two to three lines of command sequences to boot any DOS, Windows, Linux, BSD or Solaris system, making it very easy to work with.

Although GNU GRUB can be pre-packaged or retro-built into Unix-like operating systems, there are also specific GRUB implementations for DOS and Windows. GRUB can also be installed as a stand alone system unattached to any operating system. Its implementation requires one file for booting from a CD and two files for booting from a floppy, hard disk or a USB device. These files are available from any Linux Live CD that supports GRUB, making it easily and freely obtainable by computer users.

[edit] Boot process

When a computer is turned on, the computer's BIOS finds the primary bootable device (usually the computer's hard disk) and loads the initial bootstrap program from the master boot record (MBR), the first 512 bytes of the hard disk, and then transfers control to this code.

The MBR contains GRUB stage 1. Given the small size of the MBR, Stage 1 does little more than load the next stage of GRUB (which may reside physically elsewhere on the disk). Stage 1 can either load Stage 2 directly, or it can load stage 1.5: GRUB Stage 1.5 is located in the first 30 kilobytes of hard disk immediately following the MBR. Stage 1.5 loads Stage 2.

When GRUB Stage 2 receives control, it presents an interface where the user can select which operating system to boot. This normally takes the form of a graphical menu, although if this is not available or the user wishes further control, GRUB has its own command prompt, where the user can manually specify the boot parameters. GRUB can also be set to automatically load a particular kernel after a timeout period.

Once boot options have been selected, GRUB loads the selected kernel into memory and passes control on to the kernel, which then continues to start itself. At this stage GRUB can also pass control of the boot process to another loader, using chain loading, for operating systems such as Windows that do not support the Multiboot standard. In this case, copies of the other system's boot programs have been saved by GRUB; instead of a kernel, the other system is loaded as though it had been started from the MBR. This may be yet another boot manager, such as the Microsoft boot menu, allowing further selection of non-Multiboot operating systems. (This behavior is often automatic when modern Linux distributions are installed "on top of" existing Windows systems, allowing the user to retain the original operating system without modification, including systems that contain multiple versions of Windows.)

-----------------------------------------------------------------------------------------
Linux commands for this :-

step 1:- (Move to boot folder)
cd /boot/grub

step 2:- (edit the menu.lst as per your design)

see the grub editor file:-
vim menu.lst (else use gedit )

# 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

## 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=4aceaf01-4d11-4d24-82fa-be463fcb6358 ro

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

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

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

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##

title Ubuntu 8.04.2, kernel 2.6.24-24-generic
root (hd0,2)
kernel /boot/vmlinuz-2.6.24-24-generic root=UUID=4aceaf01-4d11-4d24-82fa-be463fcb6358 ro quiet splash
initrd /boot/initrd.img-2.6.24-24-generic
quiet

title Ubuntu 8.04.2, kernel 2.6.24-24-generic (recovery mode)
root (hd0,2)
kernel /boot/vmlinuz-2.6.24-24-generic root=UUID=4aceaf01-4d11-4d24-82fa-be463fcb6358 ro single
initrd /boot/initrd.img-2.6.24-24-generic


title Ubuntu 8.04.2, memtest86+
root (hd0,2)
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 Amaresh Will we Choose 2nd OS ?:
root


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

Step3:-
-----------
If you want to change time out section:-
--------------------------------------------

By default it will be 10 second if you want to increase to 20 second then just do change 10 to second

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
#timeout 10
timeout 20

If you want to change the color of loader screen:--
---------------------------------------------------

# Pretty colours
#color cyan/blue white/blue

Just uncomment the color and you will get color background!!

change to:-

It will give normal blue background.:-

# Pretty colours
color cyan/blue white/blue

It will give blinking letter with blue background:-

# Pretty colours
color white/blue

If you have multi OS:---
----------------------------
suppose you have two OS i,e Linux and Window and linux is default OS and window is Optional OS ,

example:-

title Ubuntu 8.04.2, kernel 2.6.24-24-generic
root (hd0,2)
kernel /boot/vmlinuz-2.6.24-24-generic root=UUID=4aceaf01-4d11-4d24-82fa-be463fcb6358 ro quiet splash
initrd /boot/initrd.img-2.6.24-24-generic
quiet

title Ubuntu 8.04.2, kernel 2.6.24-24-generic (recovery mode)
root (hd0,2)
kernel /boot/vmlinuz-2.6.24-24-generic root=UUID=4aceaf01-4d11-4d24-82fa-be463fcb6358 ro single
initrd /boot/initrd.img-2.6.24-24-generic


title Ubuntu 8.04.2, memtest86+
root (hd0,2)
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 System:
root


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


Do you want to make Window as first loader ?, If so then please follow my bellow

It's dead easy just change the OS position in menu.lst like bellow,

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

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Will we Choose 2nd OS ?:
root


title Ubuntu 8.04.2, kernel 2.6.24-24-generic
root (hd0,2)
kernel /boot/vmlinuz-2.6.24-24-generic root=UUID=4aceaf01-4d11-4d24-82fa-be463fcb6358 ro quiet splash
initrd /boot/initrd.img-2.6.24-24-generic
quiet

title Ubuntu 8.04.2, kernel 2.6.24-24-generic (recovery mode)
root (hd0,2)
kernel /boot/vmlinuz-2.6.24-24-generic root=UUID=4aceaf01-4d11-4d24-82fa-be463fcb6358 ro single
initrd /boot/initrd.img-2.6.24-24-generic


title Ubuntu 8.04.2, memtest86+
root (hd0,2)
kernel /boot/memtest86+.bin
quiet


Some Interesting Stuffs!!:-
---------------------------

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Amaresh!, Choose my OS?:
root

title IndiaStudyChannel.com(Linux)
root (hd0,2)
kernel /boot/vmlinuz-2.6.24-24-generic root=UUID=4aceaf01-4d11-4d24-82fa-be463fcb6358 ro quiet splash
initrd /boot/initrd.img-2.6.24-24-generic
quiet

title IndiaStudyChannel.com (recovery mode)
root (hd0,2)
kernel /boot/vmlinuz-2.6.24-24-generic root=UUID=4aceaf01-4d11-4d24-82fa-be463fcb6358 ro single
initrd /boot/initrd.img-2.6.24-24-generic


title IndiaStudyChannel.com, memtest86+
root (hd0,2)
kernel /boot/memtest86+.bin
quiet


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



It's all about Grub,

Still you need any new option then please do comment! else feel free to give mail.

Thanks & Regards,
-Amaresh Chandra Das
http://www.indiastudychannel.com/projects/ViewProject.aspx?ProjectId=2318

No comments:

Post a Comment