5

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.

  • Possible duplicate – ojs Jan 6 '17 at 1:15
  • Mounting partitions does not help – omicronns Jan 6 '17 at 2:02
  • Mount the boot partition then update grub – GAD3R Jan 6 '17 at 9:20
  • Do os-prober folowed by update-grub – Hamza Jabbour Jan 6 '17 at 11:59
  • By "Mounting partitions does not help", I meant mounting root and boot partitions. os-prober outputs only Windows 10. update-grub afterwards finds only mint images and windows. – omicronns Jan 6 '17 at 13:11
1

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.

  • Do you know where I can find information on how to create a custom menu entry for booting an encrypted partition? – BrianHVB Jul 8 '18 at 23:36
  • @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. – Emmanuel Rosa Jul 9 '18 at 1:28
  • 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. – BrianHVB Jul 10 '18 at 3:06
  • @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/… – Emmanuel Rosa Jul 10 '18 at 14:14
  • thanks! I had managed to get it to work using a chained bootloader, but the link you provided works even better. – BrianHVB Jul 12 '18 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.