11

Kickstart gives two options to install the GRUB bootloader either on "MBR" or "first sector of /boot partition".

If we choose to install it on /boot partition then what would 512 bytes of MBR contain?

Akheel Asadi
  • 383
  • 2
  • 4
  • 10

1 Answers1

8

The MBR is used by the BIOS to load and start code from the harddisk. If you don't write anything to MBR, it will be empty and the BIOS will (usually) notify you that no operating system has been found.

This is why all operating systems write their boot code into the MBR to make sure that the user gets a bootable harddisk and can start the installed operating system. It gets interesting when you have multiple operating systems. Only one operating system can write the MBR during installation. The previous one will be overwritten and its boot code is lost.

GRUB is not only located in MBR but contains boot code that loads from a bootable partition (which partition it is depends typically from which operating system you have installed grub). Grub is also called a "boot manager", because it is able to start more than just one operating system.

If you write the boot code to the boot partition (in contrast to MBR) then this code can be started if the boot code in MBR is able to do chain loading. This is also the preferred technique, in case when GRUB does not know how to handle the operating system. It just loads the boot code from the other (native) boot loader and executes it. When grub itself knows how to start the system, it does not need to use chain loading.

schaiba
  • 7,493
  • 1
  • 33
  • 31
  • 2
    So what is the difference between `grub-install /dev/sda` and `grub-install /dev/sda1` ? – jc__ Aug 30 '16 at 14:08
  • 1
    The first one is writing boot code to the MBR. The second is writing the boot code to the first (primary) partition and will only work when you already have some other boot code in the MBR. – Martin Sugioarto Aug 30 '16 at 16:58
  • @MartinSugioarto If I understand you correctly GRUB boot loader can be installed in boot partition only when we have some other boot loader already present in MBR. Suppose Windows installed in /dev/sda1 and later linux installed in /dev/sda2 with GRUB boot loader installed in boot partition i.e. /dev/sda2 then can the windows boot loader in MBR boot linux OS,the answer will be NO,because windows boot loader do not support to boot other OS. – Akheel Asadi Sep 06 '16 at 11:20
  • It can always be installed where you want it, but it is difficult to start a system when it won't boot automatically. For trivial scenarios (and you probably want to have a trivial boot process) you would like yo have some boot code in MBR. But don't forget that you can also make a system boot using external drives and then forward the boot manager to boot other devices. – Martin Sugioarto Sep 06 '16 at 11:27