1

Say, I have 2 linux systems. They both of them have /boot/grub/grub.cfg, but the one that's used on boot is from one of them. There's no /boot partition. How is it determined which /boot/grub/grub.cfg should be used and how change that?

I have 1 physical disk, 2 partitions and UEFI/GPT.

2 Answers 2

2

It's not quite clear from your question but I believe:

  • Assuming we have two physical disks, it'll depend on where BIOS/UEFI is looking. Otherwise known as the boot order. This is slightly different with UEFI because the installer talks directly to the system to install its shim, but you could have two systems with two separate UEFI shims installed. The order is decided by the system at boot.

  • Assuming two partitions on one physical disk with BIOS, it'll depend on who wrote to the MBR (master boot record, beginning portion of the disk) last (at install, or since you ran install-grub). They can overwrite each other if you reinstall grub. update-grub should only update the local configuration.

  • Assuming two partitions, one physical disk, UEFI, both should be able to co-exist peacefully. You'll get a pick of order at boot at the system level, and each bootloader might know about the other one but they aren't competing for one MBR.

10
  • 2
    update-grub does not touch the MBR (it just regenerates grub.cfg), grub-install does.
    – fkraiem
    Apr 1, 2016 at 10:16
  • @fkraiem Interesting point, thank you. Updated.
    – Oli
    Apr 1, 2016 at 10:20
  • . You'll get a pick of order at boot at the system level, -- where? what determines which grud is used?
    – Oskar K.
    Apr 1, 2016 at 10:58
  • @OskarK. Every BIOS I've ever used has had some sort of boot order selection, either in the setup screen or as an optional PRESS F12 TO SELECT BOOT DEVICE screen. Or, commonly both.
    – Oli
    Apr 1, 2016 at 12:06
  • you didn't understand my question. how does bios know what OS are there installed? When I boot, I see the boot menu from Ubunut which contains "Ubuntu, Windows, Arch" items for booting. Why is the grub from exactly Ubuntu and not from Arch used?
    – Oskar K.
    Apr 1, 2016 at 12:48
0

I have three distributions on one SSD. The setup is UEFI/GPT. Whenever a new distribution is installed it takes control of grub.

To get the desired /boot/grub/grub.cfg to be in control, boot with that distribution and use:

$ sudo cat /boot/efi/EFI/ubuntu/grub.cfg
search.fs_uuid 8337e8c8-6461-44f2-b5fe-dfd5b6b05883 root 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

$ sudo grub-install
Installing for x86_64-efi platform.
Installation finished. No error reported.

$ sudo cat /boot/efi/EFI/ubuntu/grub.cfg
search.fs_uuid b40b3925-70ef-447f-923e-1b05467c00e7 root 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
  • The first cat reveals Ubuntu 19.04 grub is used on 8337e8c8-6461-44f2-b5fe-dfd5b6b05883
  • The grub-install command will override that with the booted distributions UUID
  • The last cat reveals Ubuntu 16.04 grub is now used on b40b3925-70ef-447f-923e-1b05467c00e7.
  • From now on only Ubuntu 16.04 update-grub command will change the grub boot menu. Running update-grub in Ubuntu 19.04 will changes it's local copy of /boot/grub/grub.cfg but not effect the boot menu.

I've created a script to give more meaningful names to grub menu options:

sed -i "s|Windows Boot Manager (on /dev/nvme0n1p2)|Windows 10|g" /boot/grub/grub.cfg
sed -i "s|Windows Boot Manager (on /dev/sda1)|Windows 10 original|g" /boot/grub/grub.cfg
sed -i "s|Ubuntu 16.04.5 LTS (16.04) (on /dev/nvme0n1p7)|Broken Ubuntu 16.04|g" /boot/grub/grub.cfg
sed -i "s|Ubuntu 19.04 (19.04) (on /dev/nvme0n1p10)|Ubuntu 19.04|g" /boot/grub/grub.cfg

Now a grub menu options change from:

2. Ubuntu 19.04 (19.04) (on /dev/nvme0n1p10)
3. Advanced options for Ubuntu 19.04 (19.04) (on /dev/nvme0n1p10)

to:

2. Ubuntu 19.04
3. Advanced options for Ubuntu 19.04

You must log in to answer this question.

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