GNU GRUB is a Multiboot boot loader: 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 .
Documentation:
(1) Install grub
grub-install /dev/sda --boot-directory /boot
## example which load OS from floppy disk
mke2fs /dev/fd0
mount -t ext2 /dev/fd0 /mnt
mkdir /mnt/boot
grub-install --boot-directory=/mnt/boot /dev/fd0
umount /mnt
###losetup: Set up and control loop devices
losetup /dev/loop0 /dev/sdb1
mount /dev/loop0 /mnt/usb
grub-install --boot-directory=/mnt/usb/bugbios --force --allow-flopy /dev/fd0
-----------
## On EFI system have to install efi partition
grub-install --efi-directory=/mnt/efi
-----------
## For removable
grub-install -efi-directory=/mnt/efi --boot-directory=/mng/usb/boot --removable
Make a rescue CD-Rom
grub-mkrescue -o grub.iso
-----------
Include other files in the images
mkdir iso
mkdir -p /iso/boot/grub
grub-mkrescue -o grub.iso iso
If device map file exist, grub-probe read it into map BIOS drives to OS devices. The device map file consist of :
(device) file
BIOS knowledge:
MBR: used on PC BIOS platform, called Master Boot Record. This format allows up to four primary partitions and additional logical parititions;
There are two ways to install grub: (1) install grub between MBR and first partition; (2)core image installed in filesystem and the list of block
stored in the first sector of the partition;
GTP: GUID Partition Table format, as specified in the Extensible Firmware Interface; Use this format can reserve a whole parition for GRUB, Called
BIOS Boot Partition
### parted for grub
parted /dev/disk set partition-number bios_grub on
### If use gdisk, set partition type to "0xEF02"