[SOLVED] I accidentally emptied the EFI-partition, but have not yet turned off my PC. How can I restore the files?

Aug 3, 2021
14
1
10
Hi,

The problem arised when I wanted to copy some files from my HDD onto a USB-stick. When I selected the USB-drive on my PC, I saw there were some files on there I did not recognize and figured I didn't need them, so I promptly deleted them. However, on second glance, I saw I did not select my USB-drive, but the EFI-partition. So I accidentally removed all files from the EFI-partition instead of from my USB-drive (I did shift+delete, too, so they are not still in my recycling bin). However, recognizing my mistake, I figured it would be best to leave my PC on, so that I could restore the EFI-partition, since I assume booting my PC will now be impossible. How can I restore my EFI-partition before I shut down my PC? How do I know which files to copy to that partition? I have been looking around on the internet, but they all talk about restoring the entire partition. The partition is still on my PC, however, it just does not have any files on it.
 
Solution
Hi,

The problem arised when I wanted to copy some files from my HDD onto a USB-stick. When I selected the USB-drive on my PC, I saw there were some files on there I did not recognize and figured I didn't need them, so I promptly deleted them. However, on second glance, I saw I did not select my USB-drive, but the EFI-partition. So I accidentally removed all files from the EFI-partition instead of from my USB-drive (I did shift+delete, too, so they are not still in my recycling bin). However, recognizing my mistake, I figured it would be best to leave my PC on, so that I could restore the EFI-partition, since I assume booting my PC will now be impossible. How can I restore my EFI-partition before I shut down my PC? How do I know...
Unless you have some very weird setup, what existed on the USB is irrelevant.
That is not what you boot from.

Power off, disconnect the USB...
What happens?

No, I know, I just mentioned the USB to explain what went wrong when I deleted files from the EFI-partition. I don't want to power off the PC, since my EFI-partition is now empty and I assume it won't be able to boot Windows when I power it back on.
 
Run the free version of easybcd and go to either the repair or redeploy bcd tabs.
If anything confuses you look up some guides, it's a very well known program.

Since you are still in windows make sure to download a windows installation media and burn it to a usb stick, if you do anything wrong you can boot from that and do a few boot repairs until it fixes the issue.
(download a linux distro to a different usb for double the protection)
 
  • Like
Reactions: Platina32
How can I restore my EFI-partition before I shut down my PC?
How do I know which files to copy to that partition?
Can you show screenshot with output for bcdedit command? Run it from elevated command prompt.

BTW - easybcd is showing - all is fine with EFI partition.

 
  • Like
Reactions: Platina32
Can you show screenshot with output for bcdedit command? Run it from elevated command prompt.

BTW - easybcd is showing - all is fine with EFI partition.


https://ibb.co/qNmGczn
 
Bcdedit is showing bcd store being fine.
But you may have deleted some other necessary files.

Execute following from elevated command prompt. This should fix, if any necessary bootloader files are missing.
And show result of those commands.
diskpart
list disk
select disk 0
list partition
select partition x
(select 100MB EFI system partition, x=2 or x=3)
assign letter=H
exit
bcdboot C:\windows /s H:
 
  • Like
Reactions: Platina32
So I just discovered that when I insert the USB-drive, the H-drive shows in Total Commander, together with whatever is on the USB-drive on a separate drive (if that makes sense). It also shows the H-drive as not empty anymore...
 
Bcdedit is showing bcd store being fine.
But you may have deleted some other necessary files.

Execute following from elevated command prompt. This should fix, if any necessary bootloader files are missing.
And show result of those commands.
diskpart
list disk
select disk 0
list partition
select partition x
(select 100MB EFI system partition, x=2 or x=3)
assign letter=H
exit
bcdboot C:\windows /s H:

https://ibb.co/BgMzsK7

I'm scared to assign the letter H to it, since apparently that's already in use by something? I'm starting to think that whatever I deleted was not on the actual EFI-partition, but maybe from the bootable USB?
 
Disconnect USB drive first.

I did that and it removes the H-drive from the list of drives. I think that I have two partitions on my USB-drive, one of them called H and I removed stuff from there, instead of from the actual EFI-partition. If that makes sense. But @USAFRet told me to keep the USB-drive out of the story, so I will do that from now on, haha.