0% found this document useful (0 votes)
123 views13 pages

GRUB

The document discusses developing a C++ tool to select and display the boot partition using GRUB2. It provides background on GRUB, explaining that it is a boot loader that allows selecting between multiple operating systems. It describes how GRUB works by replacing the MBR and pointing to the /boot partition, with grub.cfg providing boot options. The implementation section notes that the tool reads the boot partition from /usr/sbin, stores it in a buffer, uses system() to execute shell commands, and calls grub-probe and os-prober to detect partitions and operating systems.

Uploaded by

Nikhil Judge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views13 pages

GRUB

The document discusses developing a C++ tool to select and display the boot partition using GRUB2. It provides background on GRUB, explaining that it is a boot loader that allows selecting between multiple operating systems. It describes how GRUB works by replacing the MBR and pointing to the /boot partition, with grub.cfg providing boot options. The implementation section notes that the tool reads the boot partition from /usr/sbin, stores it in a buffer, uses system() to execute shell commands, and calls grub-probe and os-prober to detect partitions and operating systems.

Uploaded by

Nikhil Judge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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

You might also like