Vous êtes sur la page 1sur 13

Anil Chaudhary

L.V Ramesh
Nikhil Judge
Rajnish Kumar
Shinsmon Varghese
Vivek Mahto
Write a program in C++ to develop a tool
using GRUB2 select and display a boot
partition
Understanding problem statement:
What is GRUB?



What is boot partition.


How to Display boot partition.


What is GRUB ?
GNU GRUB (short for GNU GRand Unified Bootloader) is a boot loader
package from the GNU Project.

It provides a user the choice to boot one of multiple operating systems.

Briefly, a boot loader is the first software program that runs when a
computer starts.

It is responsible for loading and transferring control to the operating system
kernel software .

The kernel, in turn, initializes the rest of the operating system.

How does GRUB work?

When a computer boots, the BIOS transfers control to the first boot device, which
can be a hard disk, a floppy disk, a CD-ROM, or any other BIOS-recognized
device.

The first sector on a hard is called the Master Boot Record (MBR).

GRUB replaces the default MBR with its own code.

Since MBR is too small to contain all the boot data.

MBR points to /boot partition where all the required files are present.

/boot/grub contains grub.cfg which provides all the complex user interface and
options on booting.

Grub.cfg
Contains the actual code to be run at the time of booting.

Menu Entry used to select the operating system is made by config.

It is made by running shell script grub-mkconfig.

Grub-mkconfig in turn runs scripts 00_header, 10_linux, 30_os-prober,05_debian_theme.

10_linux:-It loads the information about the os from which grub-mkconfig is run.

30_os-prober:-It detects and loads the information about all other operating systems.

05_debian_theme:-The settings in this file set the GRUB 2 background image, text colors,
selection highlighting and themes. In the absence of a splash image, this file sets a
monochromatic theme for the initial menu display.






Customize GRUB by grub.cfg
Change Background

Add menu Entries

Add Sounds

Change font colour and size


Implementation


We read the boot partition from /usr/sbin

Then we stored the stores data into buffer by using
sprint()

Used system() to execute shell commands in c
program.

/usr/sbin/grub-probe this executable returns the boot
partion of the current os running.

Os-prober utility to search all available Operating
Systems


Algorithm





Initialize variables

Call lsb_release

Display current OS

Call /usr/sbin/grub-probe

Call os-prober

Search and display other operating systems

Prompt user to select which boot partition to display

Produce output

End

Thank You

Vous aimerez peut-être aussi