You can recover from an accidentally deleted UEFI partition by booting a Linux Mint live USB, creating a new FAT32 EFI System Partition, mounting it correctly, and reinstalling GRUB. This process restores the bootloader files without affecting your existing data or operating system installations.
Understanding the Damage
The Unified Extensible Firmware Interface (UEFI) relies on a specific partition type known as the EFI System Partition (ESP). This partition is formatted with FAT32 and contains the bootloader binaries, such as shimx64.efi, grubx64.efi, and MokManager.efi. When you delete this partition, the firmware loses its reference point for loading the operating system kernel. Unlike Legacy BIOS, which looks for a specific sector on the disk, UEFI reads directly from the file system of the ESP. Without these files, the computer cannot hand off control to Linux Mint, resulting in a "No Boot Device Found" or similar error.
Recovery is straightforward because the actual Linux root filesystem and user data remain intact on other partitions. You only need to reconstruct the small boot container. It is crucial to identify the correct disk device before proceeding. Using hardcoded names like /dev/sda1 is dangerous because device assignments change between boots or when external drives are connected. Always use lsblk or fdisk -l to identify your target disk dynamically, typically represented as $DISK in our instructions.
Boot from Live Media
Insert the Linux Mint installation USB drive and reboot your computer. Access the boot menu, usually by pressing F12, F9, Esc, or Del during startup, depending on your motherboard manufacturer. Select the USB drive to boot into the live environment. Once the desktop loads, open a terminal window. This environment provides all the necessary tools, including parted, mkfs.vfat, and grub-install, to repair your system.
If you have dual-booted systems, ensure you know which partition belongs to your Linux installation. Refer to How is the grub boot menu presented if the gpt looks for efi system partition to understand how GPT structures guide the bootloader search. In a standard setup, your Linux root partition is likely ext4 or btrfs, while the new ESP will be fat32.
Create the New EFI Partition
First, identify your main hard drive. Run lsblk to list block devices. Identify the disk containing your Linux installation, for example, sda or nvme0n1. We will refer to this base disk as $DISK. Do not include the partition number (e.g., use sda, not sda1).
- Identify free space: Check the current partition table with
sudo fdisk -l $DISK. Look for unallocated space at the end of the disk. If you deleted the old ESP, there should be a gap. If no space exists, you may need to shrink another partition usinggpartedorparted. - Create the partition: Use
partedto create a new partition. For example:
Replacesudo parted $DISK mkpart primary fat32 1MiB 513MiB sudo parted $DISK set 1 esp on1with the actual partition number created. The size should be at least 512MB to accommodate future updates and multiple OS bootloaders. - Format the partition: Format the new partition as FAT32. Let's assume the new partition is
$ESP_PART(e.g.,sda1).
Verify the UUID if needed, but GRUB does not strictly require it for basic functionality.sudo mkfs.vfat -F 32 /dev/$ESP_PART
Mount Filesystems Correctly
Proper mounting order is critical for chroot environments. A common mistake is binding the virtual filesystems before mounting the root partition. The correct sequence ensures that the temporary environment sees the real hardware.
- Mount the root partition: Mount your Linux root filesystem first. Assume it is
$ROOT_PART(e.g.,sda2).
If you have separate home or boot partitions, mount them now undersudo mount /dev/$ROOT_PART /mnt/mnt/homeor/mnt/boot. - Bind virtual filesystems: Now bind the essential system directories. This allows the chroot environment to access devices, processes, and temporary files.
Thesudo mount --types proc /proc /mnt/proc sudo mount --rbind /sys /mnt/sys sudo mount --make-rslave /mnt/sys sudo mount --rbind /dev /mnt/dev sudo mount --make-rslave /mnt/dev--make-rslaveflag is vital. It ensures that mount events inside the chroot do not propagate to the host system and vice versa, preventing potential conflicts with udev rules. - Mount the new ESP: Finally, mount the newly created EFI partition to
/mnt/boot/efi. Note that some distributions expect the ESP at/boot/efirather than just/boot. Check your/etc/fstabin the live session if unsure, but/boot/efiis standard for Mint.sudo mkdir -p /mnt/boot/efi sudo mount /dev/$ESP_PART /mnt/boot/efi
Reinstall GRUB
Now that the environment is set up, chroot into your installed system. This changes your root directory to the mounted Linux installation, allowing you to run commands as if you were booted normally.
sudo chroot /mnt
Inside the chroot, reinstall GRUB to the new EFI partition. Replace $DISK with your base disk name (e.g., sda, not sda1).
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=linuxmint --recheck
This command copies the necessary EFI binaries to the new partition and registers the bootloader with the UEFI firmware. If you encounter errors related to Secure Boot, note that most modern Linux distributions support Secure Boot out of the box. However, if you previously disabled Secure Boot in your BIOS, ensure it remains disabled, or sign the kernels if you wish to keep it enabled. Refer to Understanding the Loading of Modules by initramfs in Linux if you face module loading issues after reboot, as the initramfs must correctly locate the root device.
After successful installation, update the GRUB configuration to reflect any changes.
update-grub
Exit the chroot environment with exit and unmount the partitions in reverse order: umount /mnt/boot/efi, then umount /mnt/sys, umount /mnt/dev, and finally umount /mnt. Reboot your system and remove the USB drive. Your Linux Mint installation should now appear in the boot menu.
Frequently Asked Questions
Will deleting the UEFI partition erase my personal files?
No, deleting the EFI System Partition only removes bootloader files, not your documents, photos, or applications stored on the root partition. Your data remains safe on the ext4 or btrfs partition, provided you do not accidentally format that specific partition during recovery.
Why did I get an error about 'esp' flag not being set?
The UEFI firmware specifically looks for a partition with the EFI System Partition attribute flag set. If you created a partition without setting this flag using parted set N esp on, the firmware will ignore it. Always verify the flag is active before rebooting.
Can I use Windows Boot Manager instead of GRUB?
While possible, it is generally not recommended for Linux Mint users. GRUB provides better integration with Linux features like hibernation and custom kernel parameters. Mixing boot managers can lead to complex configuration issues, as detailed in Non-sense Situation and Limiting Issue When Dual Booting Ubuntu into a Windows Pre-installed HP Laptop.
What if my system still doesn't boot after reinstalling GRUB?
Check your BIOS/UEFI settings to ensure the new "linuxmint" entry is selected as the primary boot option. Sometimes, the firmware retains the old, deleted entry. Navigate to the Boot Order menu, find the Linux Mint entry, and move it to the top. Also, verify that Fast Boot is disabled in BIOS settings.
Is it safe to enable Secure Boot after this recovery?
Yes, Linux Mint supports Secure Boot. After reinstalling GRUB, the signed shim loaders are in place. You can enable Secure Boot in your BIOS without disabling it, as the bootloader keys are properly registered. If you experience black screens, try disabling Secure Boot temporarily to rule out key signing issues.