എന്തെങ്കിലും എഴുതണം എന്ന് വിചാരികാന് തുടങ്ങിട്ട് നാലു മാസമായി. ഞാന് ഇപ്പൊ നമ്മുടെ സ്വന്തം നാട് വിട്ടു ഒരു പ്രവാസി ആയി സിംഗപ്പൂരില് കഴിയുന്നു.
Not Many tutorials are available for Grub 2, So I thought of writing one!
Grub 2 configurations are stored in 3 locations
- /boot/grub/grub.cfg -
Main config file NOTE : This file should not be edited by hand.
2.) /etc/grub.d/-
This is the grub scripts directory.These scripts are building blocks from which the grub.cfg file is built. When the relevant GRUB command is executed, the scripts are read in a certain sequence and grub.cfg is created.
Sample grub.d contains the following files..
00_header is the script that loads GRUB settings from /etc/default/grub, including timeout, default boot entry, and others.
05_debian_theme defines the background, colors and themes.
10_linux loads the menu entries for the installed distribution.
20_memtest86+ loads the memtest utility.
30_os-prober is the script that will scan the hard disks for other operating systems and add them to the boot menu.
40_custom is a template that canbe used to create additional entries to be added to the boot menu.
The numbering defines the precedence of the scripts.
3. /etc/default/grub -
This file contains the GRUB menu settings that are read by the GRUB scripts and written into grub.cfg. It is the customization part of the GRUB, similar to the old menu.lst, except the actual boot entries.
There are many other files also in this directory. The grub file is a text file that is parsed by the 00_header script.
Sample file:
# 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=640×480
# 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″
Note: Many more settings are available
Working
All customizations are done in /etc/default/grub and /etc/grub.d/ scripts. When the update-grub command is run, it reads the contents of the grub file and the grub.d scripts and creates the grub.cfg file.
Adding new entries/script
To add a new boot option, you will have to follow a basic syntax:
a) Create a new file that has a XX_ prefix in the name, where XX is a sequence of numbers.
b) The next step is to write the actual content. Here’s a sample:
#!/bin/sh -e
echo “Adding my custom Linux to GRUB 2″
cat << EOF
menuentry “My custom Linux” {
set root=(hd0,5)
linux /boot/vmlinuz
initrd /boot/initrd.img
}
EOF
GRUB 2 uses PARTITION notation that starts with 1 and not 0 like GRUB legacy! sda1 is now (hd0,1) and NOT (hd0,0) as before
Anything inside “cat << EOF EOF” is grub commands and outside that is interpreted by the shell.
To know about what commands grub2 suppots, you can check the link : http://grub.enbug.org/CommandList.
Make sure scripts in /etc/grub.d/ are having execute permission.
Once the script is ready, you can type update-grub
I am happy that my small blog prajizworld.com got almost 200000 hits during this short time period. It comes up in search results and its interesting.
I am sharing some of pictures here

Prajith, better known as praji. I will post more pics of praji here
Praji’s Picture

Prajith with Kiran

Prajith with kiran



Home



