Say you have a "main" GRUB on /dev/sda, with several linux kernels, and you also have a secondary linux distribution on /dev/sdb2.

The computer boots into /dev/sda GRUB. From there, how to boot the kernels in /dev/sdb2 ?

When you update-grub in the distribution in /dev/sda, the OS-prober will detect those in /dev/sdb2 and populate the GRUB menu accordingly in (/dev/sda)/boot/grub/grub.cfg.

But this is inconvenient, as when you install a new kernel or change boot options in the /dev/sdb2 distribution, this will update (/dev/sdb2)/boot/grub/grub.cfg but not the main grub.cfg.

How to get the main GRUB to read and incorporate the entries from the secondary GRUB ?


There is a GRUB command, not documented in the manual, that precisely parses a config file, extracting the entries and ignoring the remainder of the configuration : extract_entries_source. With this, any change to the secondary distribution's GRUB menu entries will be automatically taken into account in the main GRUB's menu.

In the main ("host") distribution

Add a custom entry in /etc/grub.d/40_custom :

# A dummy entry to mark the separation
menuentry "Extracted from /dev/sdb2" {

# the following if for MBR disk, change to part_gpt if necessary
insmod part_msdos
# adapt with appropriate file system module
insmod ext2
# replace aaaa-bbbb-cccc with actual partition UUID
search --fs-uuid aaaa-bbbb-cccc --set slavegrub --no-floppy
extract_entries_source ($slavegrub)/boot/grub/grub.cfg

The partition's (file system's) UUID can be obtained with blkid.

You will also want to prevent GRUB to automatically populate the menu with OS-prober. This is configured in /etc/default/grub and can be disabled globally with GRUB_DISABLE_OS_PROBER or selectively for some partitions with GRUB_OS_PROBER_SKIP_LIST (see GRUB manual).

Then you can update-grub.

In the secondary distribution

There is nothing to do as the /boot/grub/grub.cfg file will only be read for its entries and will never be actually executed. You will probably want to disable the OS-prober completely there, as those entries would be redundant when integrated within the main GRUB's menu.

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.