Thanks to @rtaft and @mook765 for helping.
I'm not very experiencing in grub internals, and actually I don't have much desire to read tons of documentation.
In my case I have to HDD:
- /dev/sda - Debian
- /dev/sdb - Ubuntu.
Both of these have their own copy of /boot/grub/grub.cfg.
Let's say I login to Debian now, it means all commands like
sudo grub-update sudo grub-set-default x
etc. will affect grub.cfg of Debian dist currently running.
Taking into account, that I don't know order of executing of these two versions of grub.cfg. I decided to change line with set default="Desired OS", in my case
set default="Debian GNU/Linux 9 (stretch) (on /dev/sda3)"
for BOTH these grub.cfg.
Summary:
- I changed
/boot/grub/grub.cfg
manually and set desired default.
- I mount second HDD (/dev/sdb -> ~/mnt_devsdb).
- I changed
~/mnt_devsdb/boot/grub/grub.cfg
manually and set desired default(the same as for p.1).
- reboot and .... voila! it works!
To boot Ubuntu I need to repeat all these steps and set proper default again.
/dev/sdb1
and view/boot/grub/grub.cfg
to see if it is pointing back to sda? – rtaft Jul 14 '20 at 17:53sudo mkdir /media/ubuntu
andsudo mount /dev/sdb1 /media/ubuntu
, Then view/media/ubuntu/boot/grub/grub.cfg
and look at the lineset default
to see what it says, I think that's the setting to look at. – rtaft Jul 14 '20 at 19:36### BEGIN /etc/grub.d/00_header ### if [ -s $prefix/grubenv ]; then set have_grubenv=true load_env fi if [ "${next_entry}" ] ; then set default="${next_entry}" set next_entry= save_env next_entry set boot_once=true else set default="0" fi
– StNickolay Jul 14 '20 at 19:57/boot/grub/grub.cfg
or{mount_point_of_sdb1/boot/grub/grub.cfg
? Which one will be used during boot process? – StNickolay Jul 14 '20 at 20:02{mount_point_of_sdb1/boot/grub/grub.cfg
) where is the Ubuntu installed set default point toset default="Debian GNU/Linux 9 (stretch) (on /dev/sda3)"
– StNickolay Jul 14 '20 at 20:05sudo grub-install /dev/sda
andsudo grub-install /dev/sdb
). Set default in Debians Grub to boot Ubuntu. When booted into Ubuntu and you want to reboot into debian do the same in Ubuntu (reinstall bootloader to both MBR) and configure Ubuntus Grub to default to Debian. – mook765 Jul 15 '20 at 12:23Set default in Debians Grub to boot Ubuntu.
Actually, currently, changing/etc/default/grub
has no effect at all. i.e. always Debian(/dev/sdaX) being loaded. – StNickolay Jul 15 '20 at 15:58/etc/default/grub
setGRUB_DEFAULT=2
(that should be Ubuntu entry), runsudo update-grub
, reinstall the bootloader (see previous comment), reboot. – mook765 Jul 15 '20 at 16:47