Restoring Bootloader/EFI partition

I deleted my EFI partition mistakenly while trying to uninstall windows from a dual boot. Now, the only partitions on my drive are a unformatted section and the partition for my filesystem (50GB). Is there anyway of getting the EFI partition back because when I use manjaro-chroot, as mhwd cannot be downloaded, it says that /boot doesn’t look like an EFI partition. Thank you. I would embed a photo, but I am not allowed to. The drive is nvme0n1 and the partition with the filesystem is nvme0n1p5

You need to recreate the EFI partiton using a partition manager and then recreate the boot images using grub, you might also have to reinstall the kernels you want to use.

https://wiki.archlinux.org/index.php/EFI_system_partition
https://wiki.manjaro.org/index.php?title=GRUB/Restore_the_GRUB_Bootloader#Use_manjaro-chroot

Maybe @Aragorn can run you through it.

Provide fdisk -l if you can.

1 Like

fdisk -l returns:

Disk /dev/nvme0n1: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: RPFTJ256PDD2MWX                         
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: C8EFA337-2FFD-43D6-B5B5-37323AF6BA3B

Device             Start       End   Sectors  Size Type
/dev/nvme0n1p5 395669504 498069503 102400000 48.8G Linux filesystem


Disk /dev/loop0: 78.44 MiB, 82251776 bytes, 160648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 568.75 MiB, 596381696 bytes, 1164808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop2: 1.28 GiB, 1379221504 bytes, 2693792 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop3: 630.5 MiB, 661131264 bytes, 1291272 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 28.65 GiB, 30765219840 bytes, 60088320 sectors
Disk model: Cruzer Snap     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot   Start     End Sectors  Size Id Type
/dev/sdb1  *         64 5443999 5443936  2.6G  0 Empty
/dev/sdb2       5444000 5452191    8192    4M ef EFI (FAT-12/16/32)

I tried to reinstall the partition, but when I created a 261 MB fat32 partition, it does not show up in lsblk.

Welcome to the forum! :slight_smile:

Um, mhwd doesn’t need to be downloaded, as it’s already on the live medium. And yes, /boot is not an EFI partition, because that’s not where the EFI partition would be mounted. The EFI system partition has to be mounted at /boot/efi ─ at least, if you’re using GRUB as the boot loader.

But okay, I’ll try talking you through it, albeit that I have no experience with NVMe drives. :crossed_fingers:

Boot up from the live medium and start the partition manager ─ it’s in the menu somewhere ─ and recreate the partition where the old one used to be. It should be about 512 MiB in size, but if the available space is smaller, then just use that space.

The partition should also be formatted with vfat (FAT32), its mount point should be set to /boot/efi, and it should have the boot and esp flags set. Don’t worry if the partitioning tool won’t let you set an esp flag ─ it may do that automatically, depending on which partitioning tool you use.

Important is to write down both the partition identifier ─ I am guessing it’ll be /dev/nvme0n1p1, but it may also have a different number as the last character ─ as well as the UUID for the formatted partition.

After doing the above, open up a terminal window and issue… :arrow_down:

su -

… to become root within the terminal session. Now, assuming that your EFI system partition is /dev/nvme0n1p1 ─ change this is needed ─ issue the following commands… :arrow_down:

manjaro-chroot -a
mount -t vfat /dev/nvme0n1p1 /boot/efi
grub-install --recheck --no-rs-codes --target="x86_64-efi" --modules="part_msdos part_gpt" --efi-directory="/boot/efi"
update-grub
nano /etc/fstab

Now make sure that you put the UUID for the new EFI system partition in place of the old one. Use Ctrl+O and Enter to save the file, and Ctrl+X to exit nano.

If all went well, you can leave the chroot with… :arrow_down:

exit

… and then it should be safe to reboot your system.

:crossed_fingers:


I see what you did there. :laughing:

5 Likes

Hello,
Thank you for this, however when I did
mount -t vfat /dev/nvme0n1p1 /boot/efi
I got an error:
mount: /boot/efi: special device /dev/nvme0n1p1 does not exist.

Oh, you said to change nvme0n1p1, well I don’t have a EFI system partition I don’t believe. I just have my filesystem unless that would be the same.

The new partition you created must be set as the EFI system partition. You do this by setting the boot and esp flags on it in your partitioning tool, and you need to do this before the chroot.

I’m sorry, but can you walk me through creating that efi partition? It’s really the only thing confusing me as I am not familiar with the linux partition programs.

I did describe it higher up, i.e. :arrow_down:

I created it on gparted, but the partition is just named “New Partition #1” and I cannot change the flags on it, or mount it.

Oh duh, I didn’t go through with the process on gparted… Alright going to try it all now.

It worked! Thank you so much. Turns out my issue was that I just wasn’t saving my changes on gparted (I’m used to windows refomatting instantly)

1 Like

Yeah you gotta confirm your changes so you don’t accidentally make a mess…

@Aragorn saves the day again. :smile:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.