Debian – Two linux distributions, grub does not detect other one

debiandual-bootgrub2linux-mint

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.

Best Answer

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.

Related Question