2

I accidentally deleted every single partition of my computer except the one that Windows is installed on it. I thought it was a good idea. But it was not.

I have no more MSR or EFI partition, so when I boot it gives an error. I have two disks, one remained untouched and the other disk has Windows on it and had MSR and EFI partitions.

Is there is a way to rebuild those ? There's no problem if it takes time or something; it's not my main computer. I just don't wanna lose the data that are on all the partitions. (since I only deleted partitions where I thought there nothing)

WHAT I'VE TRIED:

  • Boot into Windows (Tiny10, actually) installation media
  • Get a CMD working by Shift+F10
  • Run some bootrec commands I got from the web

  • Boot into Linux (MX Linux exactly) live media
  • Run GParted
  • Recreate a partition in FAT32/FAT16 (I tried both) with flags ESD

  • Install a new Linux system on a second partition (didn't worked as the EFI partition is gone)

Thanks in advance.

Similar question (if not the same): windows efi and system reserved partition mistakenly deleted (posting this to hope there's a solution with no reset)

Also, I don't much care if I can no longer use Windows

3
  • 1
    You deleted the partition (EFI) with the boot configuration data; the commands you ran require that data to exist so it can be detected. Had you not created new partitions, you might have been able to detect the deleted partitions. Your actions have made that now impossible. If you don't care about the Windows partition, you should just reinstall Windows. Why are you recovering two partitions that would only be required if you were trying to boot into Windows?
    – Ramhound
    Commented 2 days ago
  • With UEFI, the EFI boot files cannot be rebuilt directly via BootRec /FixBoot unless the EFI partition is mounted and entered first (see Steps 2 & 5), otherwise an Access Denied error will occur; instead, once the EFI partition is mounted at Y: via DiskPart: BcdBoot C:\Windows /s Y: /f UEFI (the OS partition is normally not C: in WinPE/WinRE). Once done, resolve remaining boot issues via: BootRec /FixMBR && BootRec /RebuildBCD and reboot, even if no Windows installations are found.
    – JW0914
    Commented yesterday
  • You want the data back from data partitions, yes or no? Then why bother about MSR or EFI partitions? If you want data back tell from what partitions and STOP fiddling with OS boot repair tools. Commented yesterday

2 Answers 2

3

If you want to restore your data, then start by trying to restore the data partitions, not by taking a detour somewhere else. Recovering the EFI partitions will not help you with recovering data partitions – more likely it will only be harmful, in case the process ends up creating a new EFI partition right on top of where data was.

Deleted partitions can be re-created as long as the new partition has exactly the same start sector (and as long as the tool doesn't "helpfully" erase contents). The testdisk Linux tool can be used to scan for deleted partitions.


To make the disk bootable, you'll first need to manually create and format the EFI partition using GParted or diskpart; then it can be filled in with files using bcdboot (from the Shift-F10 console), which will copy the original bootloader files from \Windows\Boot and will generate a new BCD config. See official Microsoft docs.

The MSR partition is meaningless; you can also create it using diskpart but it only exists to reserve space and not to store anything. [Not to be confused with the "System Reserved" partition of similar name that Windows uses on BIOS disks!]

  1. C:\> diskpart
    DISKPART> sel disk ...
    
  2. Create the EFI partition (efi makes DISKPART automatically set the correct GPT type guid):

    create partition efi size=100
    format quick fs=fat32 label="System"
    assign letter="S"
    
  3. Create the MSR partition if you want:

    create partition msr size=16
    
  4. Assuming the system disk is accessible at C:\Windows:

    bcdboot c:\windows /s S: /f UEFI /v
    

    /s S: tells it to specifically use the recently created partition instead of guessing; and since I don't trust "Tiny10" to properly boot in UEFI mode, /f UEFI tells bcdboot to specifically copy the EFI files even if that's not what the installer is booted through.

The procedure is almost the same for BIOS (legacy) boot as well – except instead of "EFI System" FAT32 partition you have a "Microsoft System" NTFS partition, and the DISKPART commands are slightly different, but it is still populated using the same bcdboot (/f BIOS) in the end. See Microsoft docs.

  1. Create the system partition:

    create partition primary size=100
    format quick fs=ntfs label="System"
    assign letter="S"
    active
    
  2. There is no MSR partition on BIOS/MBR disks.

  3. Use bcdboot with /f BIOS.

(There would be an additional "boot sector" step when starting from a clean disk, but the MBR boot sector was not deleted – it exists outside of any partition – so you probably don't need to reinstall it.)

8
  • 1
    TestDisk might be able to detect the deleted partitions. However, you have created partitions, so the chances of success is greatly diminished. I give up on trying to recover the two partitions and just recreate them. As for your data partition, that’s something else entirely, every single action you take on the action disk instead of a clone will decrease the chances of data recovery from a data partition
    – Ramhound
    Commented 2 days ago
  • Thanks for your reply, but while my computer is UEFI, I always kept it in Legacy mode, and my disks aren't GPT (how did I do that...) - so I don't really know what kind of partition did I deleted, but my computer surely won't boot. I think I'll have to reinstall Windows, but backing up my data is a bit of a problem: the only disk I might store my data on is locked by Windows due to it's fast startup feature - I might recreate a question to ask how to get write access on that locked disk. Or create a "temporary partition" to copy my Windows data on it using a Live Linux distro. - Thanks anyways
    – HGStyle
    Commented 2 days ago
  • Why did you specifically ask how to create the EFI partition then, if you're now telling me that you don't want it? Commented 2 days ago
  • 1
    It's because I didn't knew it wasn't a GPT disk, but thought it as the Windows Installer never booted in Legacy mode (and I temporarily enabled UEFI mode) but it still installed in Legacy mode... Yeah, I don't know what I've done.
    – HGStyle
    Commented 2 days ago
  • 1
    @HGStyle - If Windows was installed in legacy mode then it's impossible to have deleted the EFI partition. What you have asked and are now telling us are the facts cannot coexist in reality. If Windows was installed in Legacy Mode it's impossible for the disk to have been GPT. You need to fix the inconsistences in your question.
    – Ramhound
    Commented yesterday
0

Linux tools are not needed to fix Windows and are inefficient to use to do so:
WinPE/WinRE: Resolve boot issues via BootRec/BcdBoot, partition issues via DiskPart/mbr2gpt



Per OP's comment under grawity_u1686's answer, info not included within OP's question:

...[W]hile my computer is UEFI, I always kept it in Legacy mode, and my disks aren't GPT... so I don't really know what kind of partition did I deleted, but my computer... won't boot.



To Resolve:

  1. Enter the UEFI Firmware Settings:

    1. Disable: CSM Mode
      • CSM Mode's sole purpose was to enable distros lacking EFI boot the ability to boot circa <2017 (Windows ≥7 supports EFI boot)
      • CSM Mode results in performance degradation, forcing UEFI [64bit] to emulate BIOS [16bit] in a 32bit environment
    2. Enable: Secure Boot

  2. Boot a Windows Install USBOpen a terminal: Shift+F10

  3. Convert OS drive to GPT via Mbr2Gpt:

    ::# Ascertain OS drive #:
        DiskPart
    
        ::# List drives:
            Lis Dis
            Exit
    
    ::# Convert OS drive from MBR to GPT:
        Mbr2Gpt /Convert /Disk:#
    
    1. Verify Mbr2Gpt created the requisite Boot and MSR partitions:
      DiskPart
      
      ::# List drives (ensure OS drive has GPT asterisk next to it):
          Lis Dis
      
      ::# Select OS drive number:
          Sel Dis #
      
      ::# List partitions
          Lis Par
      
    2. If drive has EFI and MSR partitions: Skip to Step 5

  4. Create Boot and MSR partitions at the front of the drive:

    ::# If Dual-Booting:
        ::# Windows requires a 100MB EFI partition, whereas distros 
        ::# require different sizes, with max being ~750MB; sum both
        ::# to avoid issues
    
    Cre Par EFI Size=100
    Format Quick Fs=FAT32 Label="EFI"
    Assign Letter=Y
    Cre Par Msr Size=16
    

  5. Re-create WinRE partition at the end of the drive if it was deleted:

    ::# Verify if WinRE partition still exists:
        Lis Par
    
        ::# WinRE partition can't be deleted without an override due to
        ::# its attribute flag, so it could still exist
    
    ::# If it doesn't, select last partition on the drive:
        Sel Par #
    
    ::# Recreate WinRE partition:
        Shrink Desired=1024 Minimum=1024
        Cre Par Pri Id=de94bba4-06d1-4d40-a16a-bfd50179d6ac
        Format Quick Fs=NTFS Label="WinRE"
        Gpt Attributes=0x8000000000000001
    
    ::# Get OS partition mount point:
        Lis Vol
        Exit
    

  6. Rebuild boot files and Resolve boot issues:

    1. If Step 4 was skipped, mount EFI partition at Y: first:
      DiskPart
      
      ::# List volumes:
          Lis Vol
      
      ::# Select and mount the EFI partition:
          Sel Vol #
          Assign Letter=Y
          Exit
      
    2. ::# EFI boot files cannot be rebuilt directly via BootRec /FixBoot
      ::# unless the EFI partition is mounted and "EFI\Microsoft\Boot" is
      ::# entered first, otherwise an Access Denied error will occur
      
      ::# C: is the OS partition from Step 5:
          BcdBoot C:\Windows /s Y: /f UEFI
      
      ::# Resolve any other boot issues:
          BootRec /FixMBR && BootRec /RebuildBCD
      
      ::# Remove EFI mountpoint:
          DiskPart
      
            Sel Vol Y
            Remove
            Exit
      

  7. Reboot to Windows → Open an Admin terminal:
    WinKey+ROpen: powershellCtrl+Shift+OK

  8. Enable WinRE:

    # Ensure WinRE is disabled:
      ReAgentC /Disable
    
    # Verify if Winre.wim exists:
      ls "C:\Windows\System32\Recovery" | FindStr /I "Winre.wim" ; ls "C:\Windows\System32\Recovery" -Hidden | FindStr /I "Winre.wim"
    

    If Winre.wim:

    1. Exists:
      # Enable and verify:
        ReAgentC /Enable ; ReAgentC /Info
      
    2. Doesn't Exist:
      Extract it from a mounted Windows install ISO's install.<esd|wim>
      • ESD:
        ESDs can't be mounted, so use 7zip to extract instead
        # Get list of images [indexes] within the ESD:
          Dism /Get-ImageInfo /ImageFile:"E:\sources\install.esd"
        
        # Replace '<#>' with the Windows version index # (usually index 1: Home | 6: Pro):
          & "C:\Program Files\7-Zip\7z.exe" e '-i!<#>\Windows\System32\Recovery\Winre.wim' 'E:\sources\install.esd' -o'C:\Windows\System32\Recovery'
        
        # Enable WinRE and verify:
          ReAgentC /Enable ; ReAgentC /Info
        
      • WIM:
        Built-in way to do so, although same 7zip command can be used
        # Get list of images [indexes] within the WIM:
          Dism /Get-ImageInfo /ImageFile:"E:\sources\install.wim"
        
        # Mount WIM (usually index 1: Home | 6: Pro):
          MkDir "C:\Mount" ; Dism /Mount-Image /ImageFile:"E:\sources\install.wim" /Index:1 /MountDir:"C:\Mount" /ReadOnly
        
        # Copy over Winre.wim:
          Xcopy "C:\Mount\Windows\System32\Recovery\Winre.wim" "$env:WinDir\System32\Recovery\Winre.wim"
        
        # Unmount image, discard changes:
          Dism /Unmount-Image /MountDir:"C:\Mount" /Discard
        
        # Cleanup:
          RmDir -Recurse "C:\Mount"
        
        # Enable WinRE and verify:
          ReAgentC /Enable ; ReAgentC /Info
        
10
  • Serial Down Voter: Care to explain what precisely is wrong with the steps in this answer? (There are none, as I've tested and verified each one prior to posting)
    – JW0914
    Commented yesterday
  • Linux tools are not needed to fix Windows and are inefficient to do so Linux vs. Windows discussion most likely. :-) Commented yesterday
  • @ThorstenSchöning That's a factual statement, not an opinion: From its native boot environments WinPE/WinRE, not Linux, boot issues are resolved via BootRec and BcdBoot, with partition issues resolved via DiskPart and mbr2gpt.
    – JW0914
    Commented yesterday
  • While "Linux tools are not needed" is factual, the note about efficiency seems less so. If more care was taken initially to not damage the partition contents it would've been easier to restore the partition with testdisk.
    – JensV
    Commented yesterday
  • 1
    @JW0914 You were asking where the down-vote comes from, my comment was an educated guess about the reason. I don't think there's anything wrong with your answer, but that quoted statement might simply trigger some people. Commented yesterday

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .