Recover Fedora after EFI partition is deleted by shaking hand

Make a Fedora live USB stick, plug it in the pc and power up, when grub menu appears, type ctrl + e, using tab key find the real path when editing,

linux (hd2,gpt3)/boot/vmlinuz-5.16.12-200.fc35.x86_64 root=/dev/sda3 ro rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1
initrd (hd2,gpt3)/boot/initramfs-5.16.12-200.fc35.x86_64.img

press ctrl + x to boot.

If encounter

Cannot open access to console, the root account is locked.

It means the password of root is not set so far,

Reboot to Fedora live environment,

# /dev/sda3 is the root partition.
mkdir /tmp/sda3
mount /dev/sda3 /tmp/sda3
cd /tmp/sda3
mount -o bind /dev ./dev
mount -t proc proc ./proc
mount -t sysfs sys ./sys
chroot .
passwd root

Now we have set up root password, then retry previous step to boot in local Fedora.

sudo su

# For security, Fedora coder disables directly building loader files in EFI partition.
# we can not invoke like this: grub2-install /dev/sda

dnf reinstall grub2-efi-x64 shim-x64
dnf install grub2-efi-x64-modules

# for how to register startup item in EFI NVRAM, get it from
#grep efibootmgr /var/log/anaconda/storage.log

# we make /dev/sda1 as EFI partition.
# -c = create
# -d = disk
# -p = EFI partition number, start from 1
# -l = loader path
efibootmgr -c -w -L Fedora -d /dev/sda -p 1 -l \EFI\fedora\shimx64.efi

refer to:

Burn iso to USB stick for Windows installation

  • Rufus, released only in Windows.

  • WoeUSB, can run in Linux.

    dnf install WoeUSB
    # /dev/sdd is the u-disk
    woeusb --device /path/to/cn_windows_10_enterprise_ltsc_2019_x64_dvd_9c09ff24.iso /dev/sdd