2

I have two seperate Linux distro in two SSD.

  1. Zorin (/dev/sda)
  2. Linux Mint (/dev/sde)

First I installed Zorin then Linux Mint.

I ran bootinfoscript. Here is the gist of the result.

              Boot Info Script 0.61      [1 April 2012]


============================= Boot Info Summary: ===============================

 => No boot loader is installed in the MBR of /dev/sda.
 => No boot loader is installed in the MBR of /dev/sdb.
 => No boot loader is installed in the MBR of /dev/sdc.
 => No boot loader is installed in the MBR of /dev/sdd.
 => No boot loader is installed in the MBR of /dev/sde.

sda1: __________________________________________________________________________

    File system:       vfat
    Boot sector type:  FAT32
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        /efi/BOOT/fbx64.efi /efi/BOOT/mmx64.efi 
                       /efi/memtest86/BOOTX64.efi /efi/ubuntu/grubx64.efi 
                       /efi/ubuntu/mmx64.efi /efi/ubuntu/shimx64.efi

sda2: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info: 
    Operating System:  Zorin OS 16.1
    Boot files:        /boot/grub/grub.cfg /etc/fstab

sde1: __________________________________________________________________________

    File system:       vfat
    Boot sector type:  FAT32
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        

sde2: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info: 
    Operating System:  Linux Mint 20.3 Una
    Boot files:        /boot/grub/grub.cfg /etc/fstab

I am not sure which grub am I using. How can I know which grub I am using (the grub menu that shows up during boot)? How can I use grub from a different SSD. I want to use grub in /dev/sda (This is because I boot from this drive and I also want to customize the grub menu). How can I do that?

Update 1:

In Linux Mint efibootmgr command shows:

$ efibootmgr
BootCurrent: 0004
Timeout: 1 seconds
BootOrder: 0004,0001,0002,0003
Boot0001* UEFI:CD/DVD Drive
Boot0002* UEFI:Removable Device
Boot0003* UEFI:Network Device
Boot0004* ubuntu

I think this is the boot order maintained in my system. When I used grub-customizer in Linux Mint (in my case Boot0004* ubuntu), it changes the boot menu.

Adding the requested command outputs.

$ sudo efibootmgr -v
[sudo] password for ismail:         
BootCurrent: 0004
Timeout: 1 seconds
BootOrder: 0004,0001,0002,0003
Boot0001* UEFI:CD/DVD Drive BBS(129,,0x0)
Boot0002* UEFI:Removable Device BBS(130,,0x0)
Boot0003* UEFI:Network Device   BBS(131,,0x0)
Boot0004* ubuntu    HD(1,GPT,264abb67-bc63-46f7-8106-01f8aa3c65d2,0x800,0x100000)/File(\EFI\UBUNTU\SHIMX64.EFI)

$ lsblk -o +partuuid
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT PARTUUID
sda      8:0    0 232.9G  0 disk            
├─sda1   8:1    0   512M  0 part /boot/efi  264abb67-bc63-46f7-8106-01f8aa3c65d2
└─sda2   8:2    0 232.4G  0 part            1aa55c42-f8ba-4af5-95f1-719f0ea3f6fe
sdb      8:16   0   3.7T  0 disk            
└─sdb1   8:17   0   3.7T  0 part            97963414-695e-4e8d-a872-752afe27fcf1
sdc      8:32   0   5.5T  0 disk            
└─sdc1   8:33   0   5.5T  0 part            27e20d5e-a539-407f-b9d7-0928a78e8706
sdd      8:48   0   3.7T  0 disk            
└─sdd1   8:49   0   3.7T  0 part            13e6dcd3-161a-4c72-a49f-431b03c9f595
sde      8:64   0 223.6G  0 disk            
├─sde1   8:65   0   512M  0 part            d641c8e7-d1ed-4fb0-97d1-3d256f343bad
└─sde2   8:66   0 223.1G  0 part /          9fa068c4-b486-4044-810d-9d41a978c361
1
  • While I still use a copy of bootinfoscript, as I can include that in my backup script, I recommend Boot-Repair's BIS. It uses an updated bootinfoscript as its base & added a lot more info. And is currently updated so more details particularly on UEFI/gpt are include. help.ubuntu.com/community/Boot-Repair & sourceforge.net/p/boot-repair/home/Home I also run BIS regularly to have more info on my own system, even if no repairs required.
    – oldfred
    Jun 2, 2022 at 19:28

1 Answer 1

2

It looks like only Mint's GRUB is currently being used.

If you go to the firmware boot settings menu ("BIOS settings"), you may find that the current primary boot target is named just ubuntu instead of something like "Disk 1". UEFI allows the boot settings of installed OSs to have a clear human-readable name, and in this case it's ubuntu.

Since both Mint and Zorin are derivatives of Ubuntu, both of them apparently default to installing their GRUB to the /boot/efi/EFI/ubuntu directory on the ESP, so the last one installed will "win" by overwriting the bootloader of the other one.

BootCurrent: 0004 shows that the Boot0004 is the configuration that booted the currently running OS instance. The PARTUUID 264abb67-bc63-46f7-8106-01f8aa3c65d2 refers to sda1, which is the EFI System Partition used with the boot configuration Boot0004. The firmware will initially load /boot/efi/EFI/ubuntu/shimx64.efi, which is the Secure Boot compatibility shim which is signed by Microsoft. It will load and verify /boot/efi/EFI/ubuntu/grubx64.efi.

(The filesystem mounted to /boot/efi is FAT32, and according to the UEFI specification, it's supposed to be case-insensitive. However, some buggy UEFI firmware versions are case-sensitive. Here I'm assuming your firmware does not have such bugs.)

The firmware alone will accept bootloaders signed by either the hardware manufacturer or by Microsoft; the shimx64.efi adds Canonical's signing key and optionally the Machine Owner's Key (MOK) to the allowed list (non-persistently, so shimx64.efi must be executed in every boot). With Secure Boot enabled, you will need to set up MOK if you wish to build your own custom kernels or use third-party kernel modules.

(If you need to set up a MOK, see this article on Debian Wiki. It also applies on Ubuntu and derivatives.)

/boot/efi/EFI/ubuntu/grubx64.efi is a version of GRUB with essentially all GRUB modules built in and signed by Canonical to comply with Secure Boot requirements It comes from package grub-efi-amd64-signed. Because it's signed by Canonical, not by Microsoft, Canonical will be able to provide security updates to GRUB in a timely manner if required.

(When Secure Boot is in effect, GRUB won't be able to load GRUB modules as needed, since a Secure Boot-compliant firmware will mark all data that is not loaded from validly signed Windows-style PE+ binaries as non-executable for the CPU. Since GRUB modules use Unix-style ELF binary format instead of PE+, the firmware will not know how to check them even if the modules are cryptographically signed.)

There is probably a minimal GRUB configuration file at /boot/efi/EFI/ubuntu/grub.cfg that only contains the minimum number of configuration lines needed to access the filesystem that contains the /boot directory and load the real /boot/grub/grub.cfg from there, identifying the filesystem by an unique UUID. If you view it with e.g. sudo cat /boot/efi/EFI/ubuntu/grub.cfg, it will probably look like this:

search.fs_uuid 11111111-2222-3333-4444-555555555555 root 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

In place of the string 11111111-2222-3333-4444-555555555555 will be the unique filesystem UUID of either sda2 or sde2: run lsblk -o +uuid and compare the UUIDs.

If you wish to change the location where the sda2's EFI/ubuntu/grubx64.efi reads its actual configuration, you can just edit /boot/efi/EFI/ubuntu/grub.cfg to point it to a different filesystem.

As the current OS seems to be Mint (= a derivative of Ubuntu), you might want to edit /etc/grub.d/40_custom on Mint to add an extra menu item to switch to Zorin's boot menu:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Switch to Zorin OS's GRUB menu' {
        search.fs_uuid <filesystem UUID of sda2 here> root
        set prefix=($root)'/boot/grub'
        configfile $prefix/grub.cfg
}

And when the Zorin OS is running, you can likewise add a menu entry to switch to Mint's GRUB configuration, in case Zorin's GRUB is ever used:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Switch to Mint's GRUB menu' {
        search.fs_uuid <filesystem UUID of sde2 here> root
        set prefix=($root)'/boot/grub'
        configfile $prefix/grub.cfg
}

If you want to have separate bootloaders for each OS, you must reinstall GRUB using a custom bootloader ID. To do that, on each OS:

  • make sure /dev/sda1 is mounted as /boot/efi
  • run grub-install --bootloader-id=mint or grub-install --bootloader-id=zorin respectively

This should result in two new instances of UEFI GRUB in directories /boot/efi/EFI/mint/ and /boot/efi/EFI/zorin/. These should also be registered as UEFI boot options named mint and zorin respectively. You will see the names in efibootmgr -v output; if your system's UEFI firmware is well designed, it will also show the names in the firmware boot order settings.

If you do this, once the boot options mint and zorin are both tested and working as intended, you may want to delete the old ambiguous ubuntu entry. That can be done with:

sudo efibootmgr -b 0004 -B
sudo rm -rf /boot/efi/EFI/ubuntu
6
  • 1
    Do not know about Mint nor Zorin, but Ubuntu's grubx64.efi has something hard coded to only use the UEFI copy of /EFI/ubuntu/grub.cfg. It used to not even put a copy of grub.cfg in any additional EFI/xxx folders. It does now add a grub.cfg into each ESP folder, but still defaults to /EFI/ubuntu/grub.cfg. Have not yet tested with 22.04 and grub 2.06 to see if still an issue.
    – oldfred
    Jun 2, 2022 at 19:32
  • @oldfred That's unfortunate, and probably should be a bug.
    – telcoM
    Jun 2, 2022 at 19:34
  • They did a fix for Kubuntu way back. In looking at grub code they hard coded Kubuntu as an alternative bugs.launchpad.net/ubuntu/+source/grub2/+bug/1242417
    – oldfred
    Jun 3, 2022 at 2:37
  • 1
    gpt2 refers to the second partition on a GPT-formatted disk, and hd4 refers to 5th disk detected by the firmware (yes, disk numbering starts from 0, while partition numbering starts from 1). The UUID is the primary ID; the hd4,gpt2 is just a "hint" that tells GRUB which partition to check first to speed up the search. The hint part is optional, but assuming the firmware detects the disks in the same order as Linux does, it would be hd0,gpt2. To find out for sure, you'd need an UEFI shell and its map -r command.
    – telcoM
    Jun 3, 2022 at 8:39
  • 1
    ... or actually, the use of the ls command in a GRUB prompt would be even better solution: you can type ls (hd and then press TAB to see the possible completions, do the same for the partition identifier, and once you have a complete command like ls (hd0,gpt2)/, pressing Enter will show the contents of the root directory of that partition if GRUB understands the filesystem.
    – telcoM
    Jun 3, 2022 at 9:52

You must log in to answer this question.

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