Cloned the / partition, need to rebuild EFI

Hello,
long story short I decided to clone the full / partition from one computer to another, but I did not clone the /efi partition. I am having a hard time getting the cloned system to show up on grub/have its EFI installed. Any suggestions?

The surest way is to boot the install media in UEFI mode. Boot it to the rescue system.

Then mount your modified system, and set it up to chroot into that system. Then reinstall booting under that chroot session.

Ask if you need more details.

There’s a possible alternative. You might be able to manually setup UEFI booting using “\EFI\Boot” in the EFI partition. Of course, this does require access to the EFI partition. Again, ask if you need more details. And whether this will work is more dependent on your BIOS.

e.g. on mine, /etc/default/grub contains GRUB_DISTRIBUTOR=opensusetw. Consequently, the BIOS looks for /EFI/opensusetw/grubx64.efi on the FAT32 ESP filesystem. When the BIOS loads that file, a Grub menu should result.

Normally GRUB_DISTRIBUTOR= is blank, the result of which the BIOS looks for /EFI/opensuse/grubx64.efi. That’s fine, unless you’re multibooting, and more than one openSUSE installation needs to be bootable, in which case it can be a headache, if not preventing booting what you wish altogether.

What do cat <TWmountpoint>/etc/fstab, efibootmgr -v and lsblk -f report when you do have something booted?

I had a hard time too until I wrote down: https://karlmistelberger.wordpress.com/2019/11/19/grub-efi-btrfs/

Possibly simple copying ESP will help?

Copying the ESP does not copy NVRAM, and that’s the likely issue here.

The problem is that the ESP does not “know” about the new (cloned) root partition. Easiest is, as nrickert suggested, to UEFI-boot to rescue mode and follow Karl’s instructions, replacing /dev/sdb5 with the root partition and /dev/sdb1 with the EFI partition (ESP). (If /boot is in it’s own parition, that will have to be mounted as well.)
grub-install will then create the required .efi file in the ESP, “pointing” it to where grub is installed, creating an entry in the UEFI boot menu so it either can be selected from the UEFI-boot menu or set as the default boot (within UEFI or with efibootmgr). But for it to do this the system has to be booted in “UEFI-mode”.

Firmware needs to know about the new partition. Information is stored in NVRAM: https://en.wikipedia.org/wiki/Nonvolatile_BIOS_memory

Host erlangen has the following information related to boot:

**erlangen:~ #** efivar -l|grep Boot            
8be4df61-93ca-11d2-aa0d-00e098032b8c-**Boot**Current 
8be4df61-93ca-11d2-aa0d-00e098032b8c-**Boot**OptionSupport 
8be4df61-93ca-11d2-aa0d-00e098032b8c-Secure**Boot**
7b59104a-c00d-4158-87ff-f04d6396a915-Secure**Boot**Setup 
8be4df61-93ca-11d2-aa0d-00e098032b8c-**Boot**0000 
8be4df61-93ca-11d2-aa0d-00e098032b8c-**Boot**0001 
de8ab926-efda-4c23-bbc4-98fd29aa0069-Fixed**Boot**
8be4df61-93ca-11d2-aa0d-00e098032b8c-**Boot**Order 
45cf35f6-0d6e-4d04-856a-0370a5b16f53-Default**Boot**Order 
**erlangen:~ #**
**erlangen:~ #** efibootmgr 
BootCurrent: 0000 
Timeout: 1 seconds 
BootOrder: 0000,0001 
Boot0000* tumbleweed-nvme0n1p2 
Boot0001* tumbleweed-test 
**erlangen:~ #**

Current boot:

**erlangen:~ #** efivar -p -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-Boot0000 
GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c 
Name: "Boot0000" 
Attributes: 
        Non-Volatile 
        Boot Service Access 
        Runtime Service Access 
Value: 
00000000  01 00 00 00 7e 00 74 00  75 00 6d 00 62 00 6c 00  |....~.t.u.m.b.l.| 
00000010  65 00 77 00 65 00 65 00  64 00 2d 00 6e 00 76 00  |e.w.e.e.d.-.n.v.| 
00000020  6d 00 65 00 30 00 6e 00  31 00 70 00 32 00 00 00  |m.e.0.n.1.p.2...| 
00000030  04 01 2a 00 01 00 00 00  00 08 00 00 00 00 00 00  |..*.............| 
00000040  00 00 10 00 00 00 00 00  5f dd 18 3a 78 a9 d0 45  |........_..:x..E| 
00000050  b5 79 3c 64 b6 92 78 61  02 02 04 04 50 00 5c 00  |.y<d..xa....P.\.| 
00000060  45 00 46 00 49 00 5c 00  74 00 75 00 6d 00 62 00  |E.F.I.\.t.u.m.b.| 
00000070  6c 00 65 00 77 00 65 00  65 00 64 00 2d 00 6e 00  |l.e.w.e.e.d.-.n.| 
00000080  76 00 6d 00 65 00 30 00  6e 00 31 00 70 00 32 00  |v.m.e.0.n.1.p.2.| 
00000090  5c 00 67 00 72 00 75 00  62 00 78 00 36 00 34 00  |\.g.r.u.b.x.6.4.| 
000000a0  2e 00 65 00 66 00 69 00  00 00 7f ff 04 00        |..e.f.i.......  | 
**erlangen:~ #**

Contents of EFI System Partition:

**erlangen:~ #** find /boot/efi/ 
/boot/efi/ 
/boot/efi/EFI 
/boot/efi/EFI/tumbleweed-test 
/boot/efi/EFI/tumbleweed-test/grubx64.efi
/boot/efi/EFI/tumbleweed-nvme0n1p2 
/boot/efi/EFI/tumbleweed-nvme0n1p2/grubx64.efi 
**erlangen:~ #**

Updating grub would require booting into tumbleweed-test and executing the following:

mount /dev/nvme0n1p2 /mnt          # System Partition
mount -o bind /dev /mnt/dev
mount -o bind /proc /mnt/proc
mount -o bind /sys /mnt/sys
chroot /mnt
mount /dev/nvme0n1p1 /boot/efi     # EFI System Partition
grub2-install
grub2-mkconfig -o /boot/grub2/grub.cfg
exit

grub2-install updates file grubx64.efi and NVRAM unless told otherwise. grub2-mkconfig creates boot menu data stored in file /boot/grub2/grub.cfg: