Two linux distributions, grub does not detect other one

28,352

Even if os-prober had detected your two Linux installations, it wouldn't have been much use because it doesn't generate a GRUB2 configuration. It simply reports what it found in a machine-readable format.

Unlike GRUB legacy, which without any tools required manual configuration, GRUB2 uses a combination of generated and manual configuration.

update-grub is a wrapper for grub-mkconfig, the utility used to detect kernels in your /boot. Because grub-mkconfig uses the /boot that's mounted (perhaps it can also mount /boot based on /etc/fstab) and your Linux installations use separate /boot partitions, grub-mkconfig will only generate a configuration for the Linux distro that you're currently running. That's why from Debian, Mint was not detected, and visa versa.

Luckily, you should have some GRUB2 configuration scripts in /etc/grub.d/ which you can use to manually add entries to the GRUB2 menu.

The fix

To get both Linux installations into the same GRUB2 menu, here's what you can do.

Choose a Linux installation to be the maintainer of GRUB

You'll need to choose which Linux system you want to update GRUB from. For instance, if you choose Debian, then promise to yourself to never run update-grub from Mint.

Add custom menu entries for the other Linux installation

This can vary per Linux distro, but basically you'll need to edit the proper config file to add the menu entries for the other Linux installation. For instance, if you choose Debian to manage GRUB2, then you'll need to manually add the menu entries for Mint.

Run update-grub/grub-mkconfig

When you run update-grub, it will now use a combination of whatever it detects in /boot along with your manual configuration for the other Linux installation to produce a GRUB menu which can boot both OSes.

Additional resources

Take a look at the GRUB2 documentation for Gentoo Linux. This is not a plug, it's just that it's more detailed than Debian's equivalent documentation, and may help point you in the right direction.

Share:
28,352

Related videos on Youtube

omicronns
Author by

omicronns

Updated on September 18, 2022

Comments

  • omicronns
    omicronns over 1 year

    I have two linux distributions installed on my PC, linux Mint and Debian, both having separate boot partitions and both are installed on luks encrypted volumes. Debian was installed first, then I installed Mint. Debian was not detected by grub at Mint installation. Running update-grub on Mint also does not detect Debian. What should I do for grub to detect both distros?

    My partition structure is as follows:

    sda
    |---- sda1 (windows boot [ntfs])
    |---- sda2 (windows [ntfs])
    |---- sda3 (extended)
          |---- sda5 (debian boot [ext4]) mounted at /media/...
          |---- sda6 (debian root [crypt-luks]) mounted at /media/...
          |---- sda7 (mint boot [ext4]) mounted at /boot
          |---- sda8 (mint root [crypt-luks]) mounted at /
    

    My mint installation is running, and partitions are mounted as described above.

    sudo os-prober
    

    outputs:

    /dev/sda1:Windows 10 (loader):Windows:chain
    

    and,

    sudo update-grub
    

    outputs:

    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-4.4.0-57-generic
    Found initrd image: /boot/initrd.img-4.4.0-57-generic
    Found linux image: /boot/vmlinuz-4.4.0-53-generic
    Found initrd image: /boot/initrd.img-4.4.0-53-generic
    Found memtest86+ image: /memtest86+.elf
    Found memtest86+ image: /memtest86+.bin
    Found Windows 10 (loader) on /dev/sda1
    done
    

    Both found linux images are mint images.

    • ojs
      ojs over 7 years
      Possible duplicate
    • omicronns
      omicronns over 7 years
      Mounting partitions does not help
    • GAD3R
      GAD3R over 7 years
      Mount the boot partition then update grub
    • Hamza Jabbour
      Hamza Jabbour over 7 years
      Do os-prober folowed by update-grub
    • BrianHVB
      BrianHVB almost 6 years
      any update on this? If you used the answer below, what did your Grub menu entry look like? I'm in a similar situation. Two different Linux versions installed on removable storage. Each having its own separate boot partition, and each encrypted using Luks. I can install Grub and have it show one or the other, but not both. I don't know how to create a menu entry for booting an encrypted partition.
  • BrianHVB
    BrianHVB almost 6 years
    Do you know where I can find information on how to create a custom menu entry for booting an encrypted partition?
  • Emmanuel Rosa
    Emmanuel Rosa almost 6 years
    @BrianHVB, what exactly do you mean by an "encrypted partition"? If you're referring to the root filesystem being encrypted with LUKS, for example, GRUB is not involved in that at all.
  • BrianHVB
    BrianHVB almost 6 years
    Yes, I'm referring to a LUKS encrypted root partition alongside an unencrypted boot partition. I'm looking for a way to create a menu entry similar to this but that will target a different boot partition on the same drive. And while I understand that GRUB isn't responsible for actually decrypting the container, I think it is responsible for starting the process.
  • Emmanuel Rosa
    Emmanuel Rosa almost 6 years
    @BrianHVB, GRUB starts the process by merely delegating to initrd. It is the system's initrd that's responsible for prompting you for the LUKS passphrase and taking it from there. Since you've got multiple distros, perhaps this will help: unix.stackexchange.com/questions/343632/…