Adding EFI boot partition on new hard disk to the grub2 table

Hello,
as i added an old linux hard disc (with an EFI boot partition) to my new tumbleweed system and later did a NVIDIA driver update, followed by a call of mkinitrd,
i noticed that grub2 had listed the old linux installation after a restart.
I guess that during the mkinitrd the grub2 table was updated and the EFI partition on the old hard disk was auto detected.

The reason i am asking is, that my plan is to install windows 10 on this old hard disk and i think there are two potential problems:

  1. until i change something, the old linux EFI boot partiton on this old hd is still listed in grub2, which can be the cause conflicts when i try to select the old linux boot option, i think.
    So thats why
  2. i need to add the windows EFI partition to the grub2 table because i plan to keep my current tumbleweed hard disk as primary boot device.

Is calling mkinitrc again, the solution to both of the problems or is there an more direct way? maybe to call the grub2 auto detecting routine directly?

Hi
I would from Tumbleweed prepare the disk for your windows 10 install and use the efi partition on the second disk remove the tumbleweed one and complete the install of windows 10.

You can then re-add the Tumbleweed disk, boot from that, then if you go into YaST bootloader, make sure the check box is marked to check for other OSes and it will probe the second disk and add to grub.

For example I have;


lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 111.8G  0 disk
├─sda1   8:1    0   260M  0 part efi partition for SLED and openSUSE 42.2
├─sda2   8:2    0    40G  0 part openSUSE Tumbleweed
├─sda3   8:3    0    40G  0 part SLED
└─sda4   8:4    0  31.5G  0 part DATA
sdb      8:16   0 111.8G  0 disk
├─sdb1   8:17   0   300M  0 part windows 10 recovery 
├─sdb2   8:18   0   100M  0 part efi partition for windows 10 and openSUSE Tumbleweed
├─sdb3   8:19   0   128M  0 part windows reserved partition
├─sdb4   8:20   0  62.9G  0 part windows 10
├─sdb5   8:21   0   450M  0 part windows update partition
├─sdb6   8:22   0     8G  0 part [SWAP]
└─sdb7   8:23   0    40G  0 part openSUSE Tumbleweed

Tumblweed is the default grub and set via the efibootmgr to tweak the efi nvram entries.

I am not completely clear on what you are trying to do.

Firstly, note that how the system handles two EFI partitions may depend on the firmware (or BIOS).

Secondly, there’s no need to have a separate EFI partition.

I’ll note that I have two computers using UEFI. On both of them, I have an EFI partition on each of two disks.

On one – a Dell, I am using “/dev/sda” for Windows and “/dev/sdb” for opensuse. Windows uses the EFI partition of “/dev/sda”, while opensuse uses the EFI partition of “/dev/sdb”. I do it this way, because the Dell UEFI implementation is broken (that might not apply to all Dells). It deletes all but one EFI NVRAM entry from a particular EFI partition. So, by using two EFI partitions, I am managing to get around that.

On the other, I am only using the EFI partition on “/dev/sda”. I do have an EFI partition on “/dev/sdb”, and I occasionally backup the main EFI partition to that. But all booting is handled by the main EFI partition (the one on “/dev/sda”.

As far as opensuse and grub is concerned, the partition that you mount as “/boot/efi” is the one that it will use. If you want to switch opensuse to use the other disk for the EFI partition, then umount the current “/boot/efi” and mount the partition on the other disk as “/boot/efi”. You will need to first format it as an EFI partition if you haven’t already done that. Then you should modify “/etc/fstab” to mount the desired partition on future boots. And then reinstall grub, as with:

# grub2-install
# shim-install  ### only needed if using secure-boot

But then you have to see whether your BIOS likes that change.

I want to have an own EFI partition on each HDD, so that i also just can switch the boot priority and boot form the the other device directly. The default case will be, that i boot from the tumbleweed hdd
and i want grub2 on the tumbleweed EFI partition to hand over to the bootloader on the other device (i.e. have Windows 10 in the list of boot options in grub).

But i think it should be possible to change it the way i want it after the installation of Windows on the seconde hdd, which i will start now.

It doesn’t work that way.

With the old style MBR booting, you were booting a device. So you could have several bootable disks.

With UEFI, you are instead booting a system (specifically, a named system that is known to the UEFI firmware). So the booting is not tied to a specific disk.

Yes, there’s a fallback to boot a device. When you boot an install USB, you are using that fallback. But then it has to be setup differently. I’m not sure of the details, but I think you would need something like:


# grub2-install --removable
# shim-install --removable

In that case the boot files do not go in an “opensuse” directory. Rather, they go in the directory “/EFI/Boot” in the EFI partition. And the file is not known as “opensuse.efi” or “shim.efi” or “grubx64.efi”. Rather, it is known as “bootx64.efi”. That’s the fallback name that the UEFI firmware uses when there are no bootable named systems known to the firmware.

If you try to do that, it is going to be a constant battle. Every time that you boot Windows, that system will attempt to set itself up as a named bootable system, and undermine your effort to have bootable devices instead of bootable named systems.

No reason not to do that but you understand the bot order is the UEFI flash memory. It can be modifies with either the UEFI boot menu or can be set with efibootmgr program (see the man page for details)

Ok i had problems installing Windows on the old linux hdd anyway, it simply did not worked (seems to be a known problem).
I changed my mind in two ways now.

  1. i decided to do it as you described, which means installing using only the EFI partition on the soon to be Windows HDD (i cannot remove the EFI partition in the Tumbleweed HDD so this has to stay but i will not use it).
  2. I have found another old linux HDD but with a MBR, i have decided that i will prepare this HDD for Windows 10.

Now i just have to find out how to do it :slight_smile:
I have deleted all partitions on the old HDD and have created a new NTFS one, currently i am in the process of creating the file system (but it seems that the process hangs on Intitializing device with zeroes: 3% … i will wait).
Then i plan to run the installer again and hope that it is able to install on it then, i expect it to create a new EFI partition on it. If this work i will try to put grub2 on this partition.
Currently it was not even possible to select the HDD as boot device, but this is probably because the modern UEFI/BIOS was not able to find an EFI partition nor a MBR on the device.

If you will be using EFI, then you will need GPT partitioning rather than traditional MBR partitioning.

btw: tumbleweed boots in secure mode, is that a problem? I did not even noticed that but it seems that it was selected during the installation and in the BIOS/UEFI the boot device is also set to secure boot, and it works.

No, that’s not a problem. It has been the default for opensuse since around 13.1. (I think you had to check a box in 12.3, but now it is checked by default).

However, if you turn off secure-boot in the BIOS/firmware, then it isn’t really doing the secure-boot checking. It is just using about the same boot path that would be used by secure-boot.

Of course it is. With EFI you load and execute binary using device path that includes reference to specific partition of specific disk.

Miscommunication.

You don’t set the firmware to boot a particular disk. You set it to boot a particular named system.

Sure, the NVRAM entry for the named system then identifies the disk and EFI partition to use for the first stage of boot.

how can i let efi-grub2 chainload a windows mbr bootloader on another hdd?
In my previous setup i was able to let efi-grub2 chainload a opensuse 13.x legacy bootloader in the mbr of another hdd, so this should be possible with a windows 10 legacy bootloader too, right?

You can’t you can not chain between different boot methods. Both have to be EFI or both MBR mixing does not work

But my last setup had a EFI-grub2 on my opensuse tumbleweed hdd (with GPT) and i had another hdd with opensuse 13.1 with a MBR, and i was able to select opensuse on boot and it worked fine.
I am definitely sure about this! i would still use this system if the EFI partition would not have died two weeks ago. Now i just want to recreate a similar configuration, with windows on a mbr hdd.

Yes, you can do that kind of mixing with opensuse. But you cannot do that with Windows.

Notice also the difference. When using the EFI grub2 to boot 13.1, you were not chain-loading. The EFI-grub was doing the complete job of loading 13.1, using only the configuration from the 13.1 grub. So you were not starting out with EFI calls to the firmware, and then switching to BIOS calls to the firmware.

Ok thanks for clearing that up.
I will just live with the situation i have now then, because i do not boot windows very often. if i want to boot into windows i can use the bios boot menu.

I am not entirely sure. I have seen description how to switch Windows from BIOS to EFI boot, and to my memory it only involved creation of ESP and installing Windows bootloader there. This suggests that the same Windows installation can actually do both. I also have seen legacy bootloaders on Windows EFI install, although it was usually OEM preinstalled image. So it may be possible to do, just need to install “other” Windows bootloader. Although of course in such cases it is easier to simply install openSUSE in another mode.