Clarifing boot process with multiple linux partitions (UEFI)

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
Post Reply
azalea4va
Level 1
Level 1
Posts: 14
Joined: Mon Feb 16, 2015 12:08 pm

Clarifing boot process with multiple linux partitions (UEFI)

Post by azalea4va »

I have my system set up to run both Windows and Linux, but it is actually quad boot because I have two partitions for windows and two for linux. (When I upgrade to a newer version, I want to be able to run the "current" version at the same time I am working on setting up the next version, so I need access to both. I feel much safer installing the new version in its own distinct partition). Making matters more complicated, I have a second drive that has a backup copy of all that is on the first drive (not RAID mirrored but weekly the second drive is updated to have the parallel contents as the first). So that is two EFI partitions and eight operating system root partitions total.

In such an environment, it is useful to know which partitions are involved as the boot process proceeds. For any for whom this might be useful, let me share how I was able to clarify how things are working on my system.

To summarize the boot process.
  1. The EFI boot firmware starts a boot program in an EFI boot partition. The BootPartition//BootProgram started is determined by a firmware table of boot options with one entry as the first default. Other options can be accessed via the firmware Boot Menu (F12 at boot time on my computer). Mint's efibootmgr can edit the firmware boot option table. On my system booting to sda1/grub is the first option.
  2. The Mint stage 1 grub EFI boot program (/EFI/ubuntu/grubx64.efi) in the selected EFI partition executes. It starts grub2, using the config file /EFI/ubuntu/grub.cfg (name is hardcoded).

    Code: Select all

    search.fs_uuid 660a54b5-f64d-427e-88a2-644ff40912c5 root hd0,gpt9 
    set prefix=($root)'/boot/grub'
    configfile $prefix/grub.cfg
    The first line specifies the root partition where grub2 will be accessed (sda9 on my system). The other two lines specify the partition/file of the config file for grub2. Caution, this process uses TWO files named grub.cfg. Lets call this second one grub.cfg(2).
  3. Grub 2 provides a menu and boots as dictated by grub.cfg(2). The operating system it boots could be on a third partition, different from the partition used in the first two steps (on my system, "set root='hd0,gpt9'"). I will call this third partition the kernel partition.
  4. An environment is created that the kernel of the operating system boots into, then the root file system is mounted from possible a fourth partition. The file system partition is specified as a parameter in the line in grub.cfg(2) that loads the kernel (on my system, "linux /boot/vmlinuz-4.8.0-53-generic root=/dev/sda9 ro"). Caution, the word "root" is being used again here with respect to a partition. To differentiate between this partition and the one in step 2 above, maybe this is better called the rootfs partition.
  5. Now that Mint is up and running, there is the /etc/fstab table which will have an entry associating a partition with the file system mounted at "/". What happens if the partition specified in /etc/fstab is different from the partition specified in grub.cfg(2) for the rootfs partition? I have not tested out what happens recently so I will not try to answer. But having them different is not a good idea, the partition specified in /etc/fstab for mount point "/" should indicate the partition that /etc/fstab file is located in. This can get tricky if /etc/fstab is copied from one partition to a backup partition.
To help me know how things are booting, I have added the following to /EFI/ubuntu/grub.cfg before the "configfile" line (with the value assigned to boot set to match the partition that contains that file).

Code: Select all

set boot='(hd0,gpt1)'
export boot
I have then adjusted /boot/grub.d/40_custom to add the following line to grub.cfg(2).

Code: Select all

menuentry 'EFI Boot Partition: '${boot}'; Grub Directory: '${prefix} { 
	echo Recall grub ...
}
Now when the system boots, that menuentry will tell me which partition was the boot partition and which was the root partition (for me the following are possible, sd[ab]1 and sd[ab][89]). If the menuentry for the linux kernel does not mention a partition ("Linux Mint 19 Cinnamon"), the kernel partition is the root partition. Otherwise, the menuentry specifies the kernel partition ("Linux Mint 18.3 Cinnamon 64-bit, with Linux 4.8.0-53-generic (on /dev/sda8)"). The rootfs partition can only be identified by "opening" a menuentry to see its contents. The "root=" parameter specifies the rootfs partition. CAUTION, I believe there is a bug in grub-mkconfig/update-grub. For the entries for kernels on partitions other than the one grub is running on, all but the first menuentry will have the WRONG rootfs partition specified. So if I am running on sda9 and run grub-mkconfig with other kernels on sda8, sdb8, and sdb9, in the created grub.cfg(2) the rootfs for all three entries will specify sda8 as the rootfs partition (where the kernels on sdb8 and adb9 should be using the rootfs on sdb8 and sdb9 respectively). This error occurs whether or not grub is configured to specificy the rootfs partition using its device name or its UUID.

FWIW
deepakdeshp
Level 18
Level 18
Posts: 8390
Joined: Sun Aug 09, 2015 10:00 am

Re: Clarifing boot process with multiple linux partitions (UEFI)

Post by deepakdeshp »

Thank you for a great post.
Please consider VMware and virtual box as virtualization solutions. Virtualization makes things easy and with snapshots it's a snap to rollback to the previous status
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help, and keeps the forum clean.
Regards,
Deepak

I am using Mint 20 Cinnamon 64 bit with AMD A8/7410 processor . Memory 8GB
azalea4va
Level 1
Level 1
Posts: 14
Joined: Mon Feb 16, 2015 12:08 pm

Re: Clarifing boot process with multiple linux partitions (UEFI)

Post by azalea4va »

Please consider VMware and virtual box as virtualization solutions.
I have and I do. Most of my Windows work (little that I do) is done in a virtual machine running on Linux.

But to run a virtual machine, one must have the host machine running first (in my case, Mint). And when one upgrades to the next version of any operting system, there is always the potential for unforseen hiccups to occur. So having access to both the old operating system and the new operating system is important (at a cost of 16GB to store the partition, trivial in todays world).
Post Reply

Return to “Installation & Boot”