19

Where is the boot loader, such as Grub, installed generally?

When I install 12.04 along side Windows on different partitions of my disk, I encountered a choice for "Device for boot loader installation". If I understand it correctly, it is to specify where to install the boot loader Grub,

I found on the internet that it is to specify the disk that contains the partitions for the OS, not any partition on the disk. E.g. disk sda, not partition sda1, sda2.

Questions:

I wonder where the boot loader installed actually on the disk?

Is it installed on any of the existing partitions for the OSes and for personal data, or does it have its own partition, which is also visible e.g. from system monitor of Ubuntu?

Thanks and regards!

6
  • 1
    The bootloader is installed on the HARD DISK and on the ubuntu's root folder (as far as I know)
    – Ravi
    May 27, 2012 at 13:52
  • (1) Does it have its own partition visible from Ubuntu system monitor, or on some existing partition? (2) By "on the ubuntu's root folder", you mean in the same partition of the installed Ubuntu, i.e. the partition for "/"? But when I chose "/" as "Device for boot loader installation", there was error in loading the OS options to boot into during starting. I can only choose the whole disk not any of its partitions as "Device for boot loader installation".
    – Tim
    May 27, 2012 at 13:55
  • Edit you title please. I think it is not according to your question
    – Ashu
    May 27, 2012 at 15:24
  • If UEFI system, part of grub is in the ESP - efi system partition which is shared with Windows boot loader. And UEFI has NVRAM that remembers entries. askubuntu.com/questions/63610/… & this was for deleting Windows but same process: askubuntu.com/questions/794725/…
    – oldfred
    Sep 19, 2017 at 19:21
  • 1
    Could you please open a new question if you have a new or follow-up question? If you tack hardly related questions onto existing questions you broaden their scope which makes them harder to answer. On top of that it likely invalidates existing answers. I took the liberty to revert the edit that adds the follow-up question. Thanks. Sep 20, 2017 at 14:15

6 Answers 6

21

The boot loader needs to be installed where the BIOS is looking for something to boot. To keep things simple, you usually have a disk drive where your computer boots from, you install a GNU/Linux system in that disk and the bootloader gets there too.

The only things you need from the bootloader are really:

  • That the BIOS is able to find it
  • That it is able to find and boot your Operating System (with Linux, you just need the bootloader to have somehow access to the kernel and, if you're using one, the initrd image.)

As far as you have these two points covered, you install it where it is more convenient and where the BIOS will look for it.

The BIOS will usually look for bootloaders in the Master Boot Record of hard drives, a small area in the beginning of the drive where you can put some code to be run. You can also have a bootloader installed at the beginning of a partition.

Bootloaders are usually small enough to fit in these small areas, and even if they don't, they must put something there so the BIOS boots the bootloader.

lilo is a simple bootloader which is installed in those areas. grub is a bit bigger, and so you install some code in those areas, which, then, loads some more code from a disk partition (where grub is said to be "installed", where its configuration file lies, along with the binary code, this is usually set to be the system /boot partition, where kernels and initrds are placed too, for convenience).

In this case, if it is prompting you for the disk, this means it's asking you on which Master Boot Record should grubget installed, that is, the disk you will be booting the computer from. That part of grub will be installed only on the disk MBR. The rest probably gets installed to the same partition as / or /boot/ of the Ubuntu system you're installing (and that rest is accessible from Ubuntu, look for directories /boot/grub/ or /grub/).

5
  • 2
    Thanks! Is that small area, ie MBR of the disk, a partition itself, or in other partitions? Does it show up in Ubuntu system monitor?
    – Tim
    May 27, 2012 at 15:11
  • 3
    No, the MBR is not a partition. It's actually the place where, along with (optional) boot code, the partition table itself gets stored. It won't appear in the system monitor, as it is not a partition and doesn't have a filesystem (at least if the "system monitor" is this: dedoimedo.com/images/computers/wubi-ubuntu-system-monitor.jpg -- the table of mounted filesystems). It won't show up in tools that show the partition table either. (It is pretty small, BTW: just 512 bytes.)
    – njsg
    May 27, 2012 at 15:38
  • 2
    Is BIOS also installed in MBR of a disk? Where is it then?
    – Tim
    May 27, 2012 at 18:57
  • 4
    No, the BIOS is in the motherboard in a small, rewritable memory chip. It deals with low-level hardware stuff and it's what deals with some details in the early stages of the computer boot process (like enabling/disabling/preparing some devices, looking for the boot device, managing network boot, and the POST). Wikipedia has an article on the boot process that you may find interesting.
    – njsg
    May 27, 2012 at 19:30
  • I think it is worth mentioning how the boot flag fits in there. That Grub does not require boot flag to work correctly, because apparently it just knows what partition contains its grub.cfg, etc. Instead the flag was required for Windows bootloader to function properly. However, some BIOSes are buggy in that they'll refuse to boot a disk at all if there's no boot flag set. So it's still worth setting.
    – Hi-Angel
    Apr 11 at 8:12
12

Grub2 is the standard boot loader for Ubuntu. As always we prefer to have highly configurable applications. Grub2 is one of these. Grub2 will install exactly to where you told it to, irrespective of this being a good idea or not.

Master Boot Record

The usual case will be the Master Boot Record (MBR) of the drive you boot your computer from. This is most likely your first (or only) harddisk /sda. This will also be the default option when installing Grub2.

Other drives

Of course this boot device can also be another harddrive, a SSD, or even an external device. Then you will have to tell Grub2 where you want it to be installed when it asks you.

Partitions

The case where you need to install Grub to a partition is rare but still it is possible, e.g. in case you use another bootloader and chainload Grub from a partition boot record.

Other bootloaders

Other bootloaders are located in the MBR as well. Grub2 will overwrite these and thus you will no longer be able to boot with these. Grub2 will take the role to boot the OS you chose from a menu displayed on boot.

Grub application and settings

The Grub application, and the settings will not fit to the master boot record due to their size. Therefore they will be installed elsewhere (again you can configure this). Usually and per default Grub2 looks for it's files on the root / partition where you installed your Ubuntu, but this can also be any other partition on any of your harddrives.

Boot partition

Some people believe that it is a good idea to have a separate dedicated boot partition for this. But you will only need this in special cases, e.g. if you installed a UEFI BIOS which needs a GUID Partition Table (GPT) to boot from.

5

It's exactly where you chose to install it when you installed Ubuntu. ubiquity prompts you for this information during installation. See below:

ubiquity grub install

If you are running a legacy system (BIOS) this will typically be the Master Boot Record of the drive you choose or the unusual choice of the Partition Boot Record of the partition you chose to install it on. If you are running a system with a Unified Extensible Firmware Interface the grub bootloader will be installed in the ESP.

Sources:

https://help.ubuntu.com/community/Grub2/Installing

https://en.wikipedia.org/wiki/BIOS

https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface

https://www.rodsbooks.com/efi-bootloaders/installation.html#accessing

Experience

2
  • Using this view, I succesfully installed on a Precision M4600 today, selecting the main /dev/sda as the boot loader device, and two ext4 formatted partitions both mounted to / (root). Thanks! Mar 18, 2021 at 3:21
  • 1
    @Tropicalrambler I'm glad that this helped, however, we shouldn't be able to mount more than one partition to / (root). I think you'll find the output of the mount | grep sd command illuminating.
    – Elder Geek
    Mar 19, 2021 at 22:17
3

I spent an hour trying to find the configuration of where GRUB is installed in Debian, because it's not stored in GRUB's own configuration files.

It turns out it's handled by debconf: debconf-show grub-pc and look for "grub-pc/install_devices".

1
  • And I spent like an hour finding this answer. For some reason mine was set to sdb and every grub update required a livecd to reinstall grub. They are rare so it took me quite a while to understand what's going on. Hopefully indeed this was going on and hopefully I won't forget it until the next update if not.
    – soger
    Mar 4, 2021 at 11:42
1

Command lsblk /dev/sda or lsblk /dev/sdb etc

will show a label /boot or /boot/efi etc indicating the partition used by the boot manager

0

It's in the MBR (see https://en.wikipedia.org/wiki/Master_boot_record , https://en.wikipedia.org/wiki/GUID_Partition_Table , https://en.wikipedia.org/wiki/UEFI . grub is a Bootloader.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .