Add

Sunday, 20 October 2013

BOOTING with GNU GRUB / GRUB2 Part I


BOOTING - GNU GRUB / GRUB2
(PART - I)

A
Hhh!! Word BOOTING!! Since from 5th standard I listening this and tried to understand but still I don’t think I finished 20% complete yet, before starting GRUB2/GNU GRUB bootloader. Let us recall few very basic concepts of booting (process of computer booting up) very first set of instructions performed when you pressed power button of your CPU. BIOS function can take few seconds and typically involves performing power-on self-test, locating and initializing peripheral devices, and then finding, loading, initializing and starting an operating system. 

·     Hard Boot/Cold Boot involves turning on the power with the on/off switch.

·   Soft Boot/Warm Boot involves using the operating system to reboot, i.e without cycling power so some of the initial operations might be skipped on a soft reboot.



Before invention of ROM (Read only memory) there were of ad-hoc methods to get a small program into memory load initial software onto the computer. Growth in the capacity of ROM evolved so much and now Hardware are providing BIOS setup ready. Some embedded systems do not require a noticeable boot sequence to begin functioning and when turned on may simply run operational programs that are stored in ROM.


GNU GRUB


Coming back to GNU GRUB/GRUB2 evolved boot loader from GRUB Legacy first software program that runs when a computer kicks off, from loading and transferring control over operating system/kernel which intern initializes the rest of the operating system (e.g. FreeBSD, NetBSD, OpenBSD, GNU/Linux and many Proprietary OS's Windows, Mac OS X. Important features in GRUB is flexibility, understands filesystems and kernel executable formats, so you can load an arbitrary operating system the way you like, without recording the physical position of your kernel on the disk.


Advantages / Features
(Promptly I couldn't understand everything however I tried to put FYR)

·     Recognize multiple executable formats: Support many of the a.out variants plus ELF. Symbol tables are also loaded.

·     Supporting non-Multiboot kernels

·     Load multiples modules:  support the Multiboot feature of loading multiple modules.

·     Load a configuration file: human-readable text configuration file with preset boot commands.

·     Provide a menu interface: listing preset boot commands, with a programmable timeout, is available

·     Have a flexible command-line interface: fairly flexible command-line interface, accessible from the menu, is available to edit any preset commands, or write a new boot command set from scratch.

·     Support automatic decompression: Can decompress files which were compressed by gzip or xz

·     Access data on any installed device: Supporting data reading from any or all floppies or hard disk(s) recognized by the BIOS

·     Be independent of drive geometry translations

·     Detect all installed ram: find all the installed ram uses advanced BIOS query technique for finding all memory

·     Support Logical Block Address mode:

·     Support network booting: Support network loading of OS images using TFTP protocol

·     Support remote terminals: support computers with no console, GRUB provides remote terminal support

G
RUB2 files structure has changed lot since GRub Legacy places its files are under three core locations:

/boot/grub2


/boot/grub2/grub.cfg - This main configuration file contains all information about the Supporting non-Multiboot kernels and is built by the grub2-mkconfig command, and it should not be edited manually by hand.


Scripts under /etc/grub.d/

It’s about shell scripts you can read and fully understand them though if you have some strong scripting experience.

device.map configuration file keeps drive device names from BIOS. The map between BIOS drives and Linux devices cannot always be guessed correctly when change the boot sequence between IDE and SCSI in your BIOS.

GRUB2 avoids this problem of device ID strings (UUIDs) or file system labels when generating grub.cfg Important that GRUB2 partition number start at 1 and not at 0 as in GRUB Legacy.

/.etc/grub.d

/.etc/grub.d these scripts are building blocks for execution of the grub2-mkconfig command from which the grub.cfg file will be built, the order of menu items in grub.cfg depends on naming convention of files, which is very much important to note which files are read in first sequence order.

00_header sets environmental variables for GRUB settings from /etc/default/grub, including timeout, default boot entry, video settings, file locations and others.

10_linux Identify Linux kernels on the root device and create menu entries for the installed distribution.

30_os-prober Search entire hard disks for other operating systems and adding it to boot menu like Windows, MacOS X.

40_custom is a template that you can use to create additional entries into grub.cfg i.e the boot menu.

These numbering defines precedence 10_linux will be executed before 30_os-prober and therefore placed higher in the boot menu order.
/etc/default/grub - This file contains the GRUB menu settings that are read by the GRUB scripts and written into grub.cfg in GRUB2 and usually includes additional environmental settings such as backgrounds and themes.


 



GURB2 working process

/etc/default/grub contains customization; 
/etc/grub.d/ scripts contain GRUB menu information and operating system boot 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.

To change the grub.cfg file, you need to edit the grub file or the scripts under grub.d.


Scripts have to be executed, You can place files of our wish in grub.d directory, once update-grub executed it execute shell scripts. If you don’t want TURNOFF executable bit EX:  20_linux_xen and 41_custom


Thanks for reading, C & C are wc

                                                                                                       to be continued....................

No comments:

Post a Comment