I came to this by google because I had this problem with a Debian Buster installation from Deboostrap, a very minimalist system to build Debian from scratch. I wanted to have my old Debian Stretch still available, so I needed a dual boot. With Debootstrap there is nothing preinstalled so I needed all the other three answers from @sever (mount unknown root filesystem), @darnir (install os-prober) and @tripledes (use custom configuration in /etc/grub.d/40_custom
). Here is how I fit it all together.
First install os-prober:
~$ sudo apt install os-prober
But os-prober will not find the old installation if its root filesystem isn't mounted. So do it (my is on /dev/sda1):
~$ sudo mkdir /mnt/oldroot
~$ sudo mount /dev/sda1 /mnt/oldroot
Now I execute grub-mkconfig
to get the grub menu entries on stdout and redirect it to a temp file:
~$ sudo grub-mkconfig > /tmp/oldmenu.cfg
Now I edit this file and delete everything except the entries for the old menus so I have just left over menuentry ... {...}
and submenu ... {...}
. Then I append it to /etc/grub.d/40_custom
:
~$ sudo bash -c 'cat /tmp/oldmenu.cfg >> /etc/grub.d/40_custom'
~$ sudo update-grup
Clean up:
~$ sudo umount /mnt/oldroot
~$ sudo rmdir /mnt/oldroot
~$ rm /tmp/oldmenu.cfg
That's it. Now each time a package executes update-grub, the entry for the old installation isn't lost and always added.