GRUB vs two Linux distributions

I am trying to use two Linux distributions on one computer. And it goes like this:

  1. one GRUB (GRUB_DISABLE_OS_PROBER=false) – the first system boots, the second bad shim signature; I get the point, I don’t disable secure boot

  2. each system has a boot partition and its GRUB – I can choose the order from BIOS and boot both systems. I try in the /etc/grub.d/40_custom file:

  • set root='hd1,gpt1' and chainloader +1 – result Bad shim signature

  • set root='hd1,gpt1' and chainloader /EFI/ubuntu/grubx64.efi – result file not found

  1. in the GRUB console, I type ls – it displays two HDDs (no system), one SSD as hd3 (?) with the first system, the end, the second SSD with the second system is missing; now surprise: I type exit and I have…. GRUB menu of the second system, it works, just how? I go back to the GRUB console (first system), exit, GRUB of the first system…. again, ls, exit, second system…. again, ls, exit, first system, again, ls, exit, second system…. each time booting up a system and resetting it again.

Anybody know how to make the file 40_custom add a menu to start the GRUB of the second system?

I hope I’ve written this clearly – meaning that deepl.com has translated it well.