linux – How is a dual boot with grub supposed to be configured?
I’ve seen some instructions but I’m really trying to understand the whole boot process. I installed debian on a drive with a partition for the OS and another partition for the user. It automatically created boot and swap partitions also. Then, using gparted, I created a new partition cloning the original debian partition. I gave it a new UUID. I updated grup options.
When I boot, I get to the grub options and I see two versions of the os. I specifically select the OS on the new partition. But when it boots and i check in the terminal, i see / is mounted from /dev/nvme0n1p2
instead of /dev/nvme0n1p5
This is what I’m confused about:
/dev/nvme0n1p1
mounts to /boot/efi
and in /boot/efi/EFI/debian/grub.cfg
there is a config file:
search.fs_uuid FIRST-DRIVE-UUID root
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
What this basically means to me is that it’s going to mount the first install, then load the grub.cfg from that first install. Now it’s already got the first install mounted as root, but to run the second install, it obviously needs to mount the second drive as root instead. So it seems like it’s loading grub from within the first install instead of loading grub BEFORE it mounts the first install?
There is a grub config file that references both installs at /boot/grub/grub.cfg
, but this is part of the first install’s partition. It seems like once this file is read, the first install has already loaded and it’s too late to select which partition to boot from. This file starts with
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
Does this config somehow need to be moved to the boot partition?
When I run update-grub or grub-mkconfig (v2.04-20) i get this output:
$ sudo grub-mkconfig -o grub.cfg
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-5.10.0-9-amd64
Found initrd image: /boot/initrd.img-5.10.0-9-amd64
Found linux image: /boot/vmlinuz-5.10.0-8-amd64
Found initrd image: /boot/initrd.img-5.10.0-8-amd64
Found Debian GNU/Linux 11 (bullseye) on /dev/nvme0n1p5
Adding boot menu entry for EFI firmware configuration
done
This would appear to reference the initrd and vmlinuz on the first install. the second install just gets found
.
Read more here: Source link