Issue
On a Windows 10/11 and Ubuntu dual-boot computer, one of two opposite problems can occur:
- Windows still starts, but the Ubuntu/GRUB choice disappears after a Windows update or boot-order change; or
- Ubuntu has been intentionally removed, but a stale ubuntu firmware entry or
\EFI\ubuntudirectory remains.
Both involve a non-Windows UEFI loader, but they require opposite actions. The first branch preserves Ubuntu and restores its firmware entry or GRUB files. The second preserves Windows and removes only the confirmed stale Ubuntu entry and directory. Do not perform both.
Firmware mode matters here because UEFI systems store loader files on an EFI System Partition and boot choices in firmware variables. The procedure detects that state; it does not ask the reader to guess a BIOS label. If the computer is using legacy BIOS/CSM boot, the UEFI commands in this page do not apply.
Searchable Windows and bootloader error codes and exact messages
| Displayed identifier | Name or exact message | When it can apply |
|---|---|---|
| No numeric code | Firmware entry ubuntu is missing, or Windows starts directly with no GRUB menu | Primary restore symptom on a previously working UEFI dual-boot system. First check one-time boot order. |
| No numeric code | Stale firmware entry ubuntu remains after Ubuntu was removed | Primary removal symptom. Confirm Linux is intentionally gone before deletion. |
Win32 error 2 / 0x00000002 | ERROR_FILE_NOT_FOUND — The system cannot find the file specified. | Can appear when Windows tries to remove or access an EFI file whose directory metadata is inconsistent or whose path was typed incorrectly. The corresponding HRESULT can be 0x80070002, but use it only if displayed. |
Win32 error 145 / 0x00000091 | ERROR_DIR_NOT_EMPTY — The directory is not empty. | rd was issued without removing contents, a file is hidden/system, or metadata is inconsistent. Inspect before repair. |
Win32 error 1392 / 0x00000570 | ERROR_FILE_CORRUPT — The file or directory is corrupted and unreadable. | Supports an EFI-volume file-system problem. Back up readable EFI content before chkdsk /f. |
| No numeric code | Windows has scanned the file system and found no problems. No further action is required. | Read-only or corrective CHKDSK found no defect. Do not claim file-system repair. |
| No numeric code | Windows made corrections to the file system. | CHKDSK changed the EFI file system. Reinspect every loader and verify both boot paths. |
| No numeric code | grub rescue> / error: no such partition / error: unknown filesystem | GRUB messages, not Windows error codes. They indicate a different GRUB/root mapping problem; preserve exact text. |
| No numeric code | EFI variables are not supported on this system. | efibootmgr or GRUB cannot access UEFI variables, often because the Ubuntu live media was booted in legacy mode or efivarfs is unavailable. Stop and reboot the media through its UEFI entry. |
Recovery status 0xc000000f | Common Windows Recovery wording: The Boot Configuration Data for your PC is missing or contains errors | Applies only if Windows Boot Manager or its BCD was damaged. Stop this Ubuntu-entry procedure and route by the complete File: and Info: lines. |
Recovery status 0xc0000225 | Common wording: A required device isn't connected or can't be accessed | Applies only if Windows itself no longer starts. Do not delete more EFI content. |
Recovery status 0xc000000e | STATUS_NO_SUCH_DEVICE; common required-device wording | Indicates Windows boot-device resolution trouble, not proof that the Ubuntu entry is responsible. |
The firmware label ubuntu and the directory name EFI\ubuntu are conventional Ubuntu identifiers. Other distributions may use different loader IDs, paths, signed shims, or boot managers and are outside the command-specific branches of this page.
Applies when
Use this procedure only when:
- Windows 10 or Windows 11 is one member of an intentional or formerly intentional Ubuntu dual-boot setup;
- disk and partition layout is stable and readable;
- UEFI boot is detected by a GPT disk plus an EFI System Partition, and for Linux-side firmware writes the live session contains
/sys/firmware/efi; - the user has explicitly chosen either restore Ubuntu access or remove stale Ubuntu boot artifacts;
- the exact Ubuntu root partition and EFI System Partition can be identified for restoration, or Ubuntu's removal can be confirmed for cleanup; and
- current EFI files and firmware entries are recorded and backed up before deletion or reinstall.
For restoration, this page is scoped to conventional x86-64 Ubuntu using GRUB 2 on UEFI. For removal, it is scoped to an ubuntu firmware object and \EFI\ubuntu directory that are no longer needed.
Does not apply when
Do not use this procedure on legacy BIOS/MBR boot, Windows-only BCD menu entries, WSL, a virtual machine's virtual firmware, Apple Boot Camp, ChromeOS, systemd-boot, rEFInd, or an unidentified Linux distribution.
Stop when:
- either Windows or Ubuntu contains unbacked-up irreplaceable data;
- the disk disappears, reports I/O errors, is RAW, or has an ambiguous/damaged partition table;
- multiple EFI System Partitions or multiple internal disks exist and the loader-to-ESP mapping cannot be proved;
- Ubuntu uses LUKS encryption, LVM, Btrfs subvolumes, a separate
/boot, RAID, or another complex layout that has not been mapped; - Secure Boot policy requires a signed shim/package sequence that the installed Ubuntu release does not support;
- the Linux root was deleted but the user now wants data recovered from it; or
- Windows displays
0xc000000f,0xc0000225,0xc000000e, or another Recovery error after an EFI change.
This page does not recreate deleted Linux partitions and does not convert firmware mode or partition style.
Information that may remain unknown
The Windows build, motherboard marketing name for UEFI, original GRUB installation date, and reason firmware boot order changed may remain unknown.
The following may not remain unknown:
- whether the goal is restoration or removal;
- whether Windows and the Ubuntu live media are booting in UEFI mode;
- the exact physical disk, GPT layout, and EFI System Partition;
- the exact Ubuntu root partition and any separate
/bootpartition for restoration; - whether
\EFI\Microsoft,\EFI\Boot,\EFI\ubuntu, and other vendor directories exist; - every current firmware entry and GUID;
- whether Ubuntu still contains needed data; and
- where the EFI backup is stored outside the EFI System Partition.
Firmware mode is not a general prerequisite for the project. It is mandatory here because a UEFI firmware-entry repair is a different mechanism from legacy GRUB-in-MBR repair.
Requirements
- Stable power and a verified backup of Windows and Ubuntu user data
- A separate external volume for EFI file backup and evidence
- Local administrator access in Windows
- Ubuntu installation media matching the installed architecture and preferably the installed Ubuntu release
- The firmware one-time boot menu key for the exact computer
- A camera or text file to preserve firmware entries, disk layout, and command output
- For restoration, reliable identification of the Ubuntu root and EFI partitions
- For removal, explicit confirmation that Ubuntu is no longer wanted and its data is already backed up or intentionally deleted
- Sufficient skill to stop when placeholders do not map exactly to the detected layout
Do not use the EFI System Partition itself as the only backup destination.
In the Windows commands below, X: means the already detected, healthy external backup volume. Replace X: with its actual drive letter after confirming its label, capacity, and physical-disk identity in Disk Management or read-only DiskPart output. X: must not be the Windows volume, an EFI/System partition, an Ubuntu partition, or another internal volume. In Linux commands, <external-backup-mount> means that same verified external device mounted separately from the target disk.
Starting position
-
Decide and write down exactly one objective:
- RESTORE: preserve Ubuntu and restore a working Ubuntu/GRUB choice; or
- REMOVE: preserve Windows and remove only stale Ubuntu boot artifacts.
-
In Windows, save all work and perform a full shutdown before Linux-side writes:
shutdown /s /t 0 -
Before shutting down, open an elevated Command Prompt and create a new, unused attempt directory on the verified external volume. Do not merge this run with files from an earlier attempt:
set "EVID=X:\FixBackup\FIX-072\Attempt-01" if exist "%EVID%\" (echo STOP: choose the next unused Attempt number & exit /b 1) md "%EVID%" || exit /b 1 echo FIX-072> "%EVID%\attempt-marker.txt" echo EVID=%EVID%>> "%EVID%\attempt-marker.txt" bcdedit /enum firmware /v > "%EVID%\firmware-before.txt" bcdedit /export "%EVID%\BCD-before"If Attempt-01 exists, change only the attempt number to the next unused value and write that exact path into the case record. Open both saved files or confirm their nonzero size before continuing. If the external destination cannot be proved or written, stop; a folder on
C:is not a substitute for the required external backup.The BCD export does not guarantee restoration of deleted UEFI NVRAM variables. It preserves Windows BCD state and must not be described as a complete firmware backup.
-
Use Disk Management or DiskPart read-only inspection to record disk and volume layout:
diskpart list disk list volume exit -
Do not format, delete, shrink, extend, convert, clean, or change partition types.
-
Use the one-time firmware boot menu once. If both ubuntu and Windows Boot Manager appear, test the intended entry before changing files.
Confirm the diagnosis
A. Confirm a restoration case
-
If the one-time boot menu contains ubuntu, select it once.
- If Ubuntu starts and GRUB can start Windows, the loader exists; only default boot order changed. Use Resolution Branch A.
- If the entry fails or is absent, continue.
-
Boot Ubuntu installation media by selecting the entry explicitly prefixed with UEFI. Choose Try Ubuntu, not Install.
-
In a terminal confirm UEFI variable access:
test -d /sys/firmware/efi && echo UEFI || { echo NOT-UEFI; exit 1; } sudo efibootmgr -v || { echo 'STOP: firmware variables cannot be enumerated'; exit 1; } sudo lsblk -o NAME,SIZE,FSTYPE,FSVER,LABEL,UUID,PARTTYPENAME,MOUNTPOINTS || exit 1 sudo blkid || exit 1 -
Stop if the result is
NOT-UEFIorefibootmgrsays EFI variables are unsupported. Reboot the media through its UEFI entry; do not change firmware settings blindly. -
Identify partitions using multiple facts:
- the EFI System Partition is FAT32, has GPT type EFI System, and contains an
EFIdirectory; - the Ubuntu root contains
etc,home,usr,var, andbootfor the installed system; - a small ext file system may be a separate
/boot, not root; - labels and size alone are insufficient.
- the EFI System Partition is FAT32, has GPT type EFI System, and contains an
-
Mount read-only first for inspection:
sudo mkdir -p /mnt/fix072-root /mnt/fix072-esp sudo mount -o ro /dev/<ubuntu-root-partition> /mnt/fix072-root sudo mount -o ro /dev/<efi-system-partition> /mnt/fix072-esp ls -la /mnt/fix072-root find /mnt/fix072-esp/EFI -maxdepth 2 -type f -print -
Confirm
/mnt/fix072-root/etc/os-releaseidentifies the intended Ubuntu installation and inspect/mnt/fix072-root/etc/fstabfor separate/bootor/boot/efimappings. -
Confirm whether
/mnt/fix072-esp/EFI/ubuntu/shimx64.efiandgrubx64.efiexist.- A verified
shimx64.efiexists and the NVRAM entry is absent: use Branch B with that signed shim path. - Only
grubx64.efiexists: do not route automatically to Branch B. Its suitability depends on the installed Ubuntu/Secure Boot design; use the exact Ubuntu release's loader recovery or Branch C to restore the appropriate shim/GRUB files. - Files are missing or damaged and the Ubuntu root is intact: use Branch C.
- Root identity or layout is ambiguous: stop.
- A verified
-
Unmount the read-only mounts before proceeding:
sudo umount /mnt/fix072-esp sudo umount /mnt/fix072-root
B. Confirm a removal case
-
Confirm Ubuntu is intentionally removed or no longer wanted and its data is backed up.
-
In an elevated Windows Command Prompt, list firmware entries:
bcdedit /enum firmware /v -
Record the GUID, description, device, and path of the exact ubuntu firmware application. Never select
{bootmgr},{fwbootmgr}, a Windows loader, diagnostics, or an entry whose path is absent. -
Confirm
S:is unused, then mount the current EFI System Partition:mountvol S: /s dir /a S:\EFI dir /a S:\EFI\ubuntu -
If more than one EFI System Partition exists or the mounted partition does not contain the path named by the firmware entry, stop and map the correct ESP by disk, volume, and file contents. Do not delete from the first FAT32 volume found.
-
Reset
ATTEMPTandEVIDto the exact new attempt path chosen in section 6 if this is a new command session. Validate its marker. Back up the complete readable Ubuntu directory to a destination that must not already exist:set "ATTEMPT=<exact-recorded-Attempt-NN>" set "EVID=X:\FixBackup\FIX-072\%ATTEMPT%" findstr /x /l /c:"FIX-072" "%EVID%\attempt-marker.txt" >nul || (echo STOP: wrong attempt directory & exit /b 1) findstr /x /l /c:"EVID=%EVID%" "%EVID%\attempt-marker.txt" >nul || (echo STOP: attempt path does not match marker & exit /b 1) if exist "%EVID%\EFI-ubuntu-before\" (echo STOP: stale backup destination & exit /b 1) md "%EVID%\EFI-ubuntu-before" || exit /b 1 robocopy S:\EFI\ubuntu "%EVID%\EFI-ubuntu-before" /E /COPY:DAT /R:0 /W:0 set "RC_UBUNTU_BACKUP=%ERRORLEVEL%" echo Robocopy exit code: %RC_UBUNTU_BACKUP% > "%EVID%\EFI-ubuntu-backup-result.txt" if %RC_UBUNTU_BACKUP% GEQ 8 (echo STOP: Ubuntu EFI backup failed & exit /b 1) powershell -NoProfile -Command "(Get-ChildItem -LiteralPath 'S:\EFI\ubuntu' -File -Recurse | Measure-Object).Count" > "%EVID%\EFI-ubuntu-source-file-count.txt" powershell -NoProfile -Command "(Get-ChildItem -LiteralPath (Join-Path $env:EVID 'EFI-ubuntu-before') -File -Recurse | Measure-Object).Count" > "%EVID%\EFI-ubuntu-backup-file-count.txt" fc /b "%EVID%\EFI-ubuntu-source-file-count.txt" "%EVID%\EFI-ubuntu-backup-file-count.txt" >nul || (echo STOP: Ubuntu EFI backup count differs from source & exit /b 1) for /f "usebackq delims=" %C in ("%EVID%\EFI-ubuntu-backup-file-count.txt") do set "EFI_UBUNTU_BACKUP_FILES=%C" if "%EFI_UBUNTU_BACKUP_FILES%"=="0" (echo STOP: Ubuntu EFI backup contains no files & exit /b 1) dir /s /a S:\EFI\ubuntu dir /s /a "%EVID%\EFI-ubuntu-before"Require the captured Robocopy exit code to be 0 through 7, no failed files in its summary, identical nonzero source/backup file counts, and the expected Ubuntu loader files in the external destination. Retain both count files for rollback. Exit code 8 or higher, unequal/zero counts, a missing destination file, an unreadable source, or a pre-existing destination is a failed backup. Stop before deletion or file-system repair.
-
Run a read-only file-system check first:
chkdsk S: -
If the directory lists normally and CHKDSK reports no errors, use Branch D. If the directory displays but file operations return Win32 error 2, 145, or 1392 and CHKDSK reports a defect, use Branch E only after backing up all readable EFI directories.
Resolution steps
Choose exactly one branch.
Branch A — Ubuntu still boots; restore only firmware boot order
-
Start Ubuntu through the one-time boot menu.
-
Confirm Windows remains available in GRUB or the firmware menu.
-
Display entries:
sudo efibootmgr -v || { echo 'STOP: firmware entries cannot be enumerated'; exit 1; } -
Use the computer's firmware setup to place the existing ubuntu entry first if GRUB is intended as the default, or leave Windows Boot Manager first if the user prefers the one-time menu.
-
Do not reinstall GRUB or rewrite EFI files when changing order alone resolves the problem.
Branch B — Ubuntu EFI files exist; recreate only the missing firmware entry
-
Boot the Ubuntu live media in UEFI mode and mount the proven ESP read-write:
sudo mkdir -p /mnt/fix072-esp sudo mount /dev/<efi-system-partition> /mnt/fix072-esp ls -l /mnt/fix072-esp/EFI/ubuntu/shimx64.efi -
Identify the physical disk and ESP partition number from
lsblk. For example only,/dev/nvme0n1p1means disk/dev/nvme0n1, partition1. Do not copy that example without matching the actual layout. -
Set
EXTto the already mounted, verified external backup path and setLEDGERto the exact attempt directory created from Windows. Require that attempt directory to exist, then create a new Branch-B subdirectory; stop if that subdirectory already exists:EXT='/media/ubuntu/REPLACE-WITH-EXTERNAL-LABEL' findmnt "$EXT" ATTEMPT='<exact-recorded-Attempt-NN>' LEDGER="$EXT/FixBackup/FIX-072/$ATTEMPT" [ -d "$LEDGER" ] || { echo 'STOP: recorded Windows attempt directory is missing'; exit 1; } tr -d '\r' < "$LEDGER/attempt-marker.txt" | grep -Fx 'FIX-072' >/dev/null || { echo 'STOP: wrong attempt marker'; exit 1; } CREATE_LEDGER="$LEDGER/BranchB-Create" [ ! -e "$CREATE_LEDGER" ] || { echo 'STOP: stale Branch-B evidence exists'; exit 1; } sudo mkdir "$CREATE_LEDGER" || exit 1 set -o pipefail sudo efibootmgr -v | sudo tee "$CREATE_LEDGER/efibootmgr-before-create.txt" || { echo 'STOP: initial firmware enumeration failed'; exit 1; }Substitute the exact recorded attempt number if it was not 01. Copy the complete original
BootOrderfrom this before file into the case record before continuing. -
Create the entry using the verified signed shim path, then immediately capture the after-state before changing order:
sudo efibootmgr -c -d /dev/<physical-disk> -p <esp-partition-number> -L ubuntu -l '\EFI\ubuntu\shimx64.efi' CREATE_RC=$? echo "efibootmgr create exit code: $CREATE_RC" | sudo tee "$CREATE_LEDGER/create-result.txt" [ "$CREATE_RC" -eq 0 ] || exit 1 sudo efibootmgr -v | sudo tee "$CREATE_LEDGER/efibootmgr-after-entry-create.txt" || { echo 'STOP: created entry cannot be enumerated; do not change BootOrder'; exit 1; }Compare the before and after files and identify the exact new
Boot####number; require its disk, partition, label, and loader path to match.efibootmgr -cnormally places the new entry first. Then explicitly apply the user's complete intended order:sudo efibootmgr -o <complete-intended-comma-separated-BootOrder> ORDER_RC=$? sudo efibootmgr -v | sudo tee "$CREATE_LEDGER/efibootmgr-after-order.txt" ORDER_LIST_RC=$?Build the complete order from the captured original order plus the new Ubuntu entry: place Ubuntu first only when the user chose GRUB as default; otherwise retain the original first entry and place Ubuntu at the intended later position. Never omit unrelated retained firmware entries or copy example numbers.
If
ORDER_RCorORDER_LIST_RCis nonzero, or the after listing does not show the complete intended order, undo this creation immediately. Replace both placeholders only with values proven by the two captures:<ORIGINAL-ORDER>is the complete original comma-separated order and<NEW-BOOT-NUMBER>is the newly created four-hex-digit number withoutBootor*:sudo efibootmgr -o <ORIGINAL-ORDER> ROLLBACK_ORDER_RC=$? sudo efibootmgr -b <NEW-BOOT-NUMBER> -B ROLLBACK_DELETE_RC=$? sudo efibootmgr -v | sudo tee "$CREATE_LEDGER/efibootmgr-after-create-rollback.txt" ROLLBACK_LIST_RC=$? printf 'rollback order rc=%s; rollback delete rc=%s; rollback list rc=%s\n' "$ROLLBACK_ORDER_RC" "$ROLLBACK_DELETE_RC" "$ROLLBACK_LIST_RC" | sudo tee "$CREATE_LEDGER/rollback-result.txt"Require the new object to be absent and every original retained object/order member to remain present. If either rollback command or the rollback enumeration fails, stop and use the firmware one-time menu; do not create another entry.
-
Stop if
shimx64.efiis absent, the command targets a different disk/partition, firmware variables are unsupported, the new object cannot be identified uniquely, or the complete intended order cannot be reconstructed from the capture. -
Unmount the ESP explicitly, restart, and test both Ubuntu and Windows from the one-time menu:
sudo umount /mnt/fix072-esp
Branch C — Ubuntu root is intact but GRUB EFI files are missing or unusable
This branch covers a conventional x86-64 Ubuntu UEFI installation. Stop for LUKS, LVM, Btrfs subvolumes, RAID, separate /boot, or other layouts unless they have been explicitly mounted according to their design.
-
Boot matching Ubuntu media in UEFI mode and confirm
/sys/firmware/efiexists. -
Mount the proven Ubuntu root and ESP:
sudo mount /dev/<ubuntu-root-partition> /mnt sudo mkdir -p /mnt/boot/efi sudo mount /dev/<efi-system-partition> /mnt/boot/efi -
Verify the mounted root before binding anything:
cat /mnt/etc/os-release cat /mnt/etc/fstab findmnt /mnt findmnt /mnt/boot/efi -
Mount the verified external backup device separately, set
EXTto its actual mount path, and setLEDGERto the exact attempt directory created from Windows. Create a new Branch-C evidence directory and backup destination; stop if either already exists. Then copy the complete readable EFI tree there before GRUB installation:EXT='/media/ubuntu/REPLACE-WITH-EXTERNAL-LABEL' findmnt "$EXT" ATTEMPT='<exact-recorded-Attempt-NN>' LEDGER="$EXT/FixBackup/FIX-072/$ATTEMPT" [ -d "$LEDGER" ] || { echo 'STOP: recorded Windows attempt directory is missing'; exit 1; } tr -d '\r' < "$LEDGER/attempt-marker.txt" | grep -Fx 'FIX-072' >/dev/null || { echo 'STOP: wrong attempt marker'; exit 1; } GRUB_LEDGER="$LEDGER/BranchC-GRUB" [ ! -e "$GRUB_LEDGER" ] || { echo 'STOP: stale Branch-C evidence exists'; exit 1; } sudo mkdir "$GRUB_LEDGER" || exit 1 EFI_BACKUP="$GRUB_LEDGER/EFI-all-before" sudo mkdir "$EFI_BACKUP" || exit 1 sudo cp -a /mnt/boot/efi/EFI/. "$EFI_BACKUP/" CP_RC=$? echo "EFI copy exit code: $CP_RC" | sudo tee "$GRUB_LEDGER/efi-copy-result.txt" [ "$CP_RC" -eq 0 ] || { echo 'STOP: EFI backup copy failed'; exit 1; } sudo find /mnt/boot/efi/EFI -type f | wc -l sudo find "$EFI_BACKUP" -type f | wc -l sudo find "$EFI_BACKUP" -maxdepth 3 -type f -printSubstitute the exact recorded attempt number if it was not 01. Require the captured
cpexit code to be zero, equal nonzero file counts, and visible copies of the existing Microsoft loader files and any readable Ubuntu files. If the external device is not mounted or validation differs, stop beforegrub-install. -
Recursively bind the live system interfaces so submounts—including EFI variables under
/sys—are visible inside the chroot, then enter the installed system:for i in /dev /proc /sys /run; do sudo mount --rbind "$i" "/mnt$i"; sudo mount --make-rslave "/mnt$i"; done sudo chroot /mnt -
Inside the chroot, verify the ESP mount and require an actual
efivarfsmount before any GRUB write. These gates must succeed;test -dalone is insufficient:mountpoint /boot/efi || { echo 'STOP: ESP is not mounted at /boot/efi'; exit 1; } findmnt -n -t efivarfs /sys/firmware/efi/efivars || { echo 'STOP: efivarfs is not mounted; reboot live media in UEFI mode'; exit 1; } grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck || { echo 'STOP: grub-install failed'; exit 1; } update-grub || { echo 'STOP: update-grub failed'; exit 1; } efibootmgr -v || { echo 'STOP: efibootmgr verification failed'; exit 1; } -
Require successful completion. If GRUB reports a signed-loader/Secure Boot conflict, missing package, unsupported EFI variables, wrong architecture, or missing
/boot/efi, stop and use the exact Ubuntu release's signedgrub-efi/shimrecovery procedure. -
Exit and recursively unmount in reverse order so the
/sysEFI-variable submount and/devsubmounts are not left attached:exit for i in /run /sys /proc /dev; do sudo umount -R "/mnt$i"; done sudo umount /mnt/boot/efi sudo umount /mnt -
Unmount the external backup device cleanly, restart, remove the live media, and test Ubuntu and Windows separately from the one-time boot menu.
Branch D — Remove a healthy, confirmed stale Ubuntu entry and directory
-
Reconfirm the exact Ubuntu firmware GUID and the externally backed-up
S:\EFI\ubuntudirectory. ResetEVIDto the exact recorded attempt directory if necessary. Recheck the saved Robocopy result: exit code 0–7, zero failed files, and the expected loader files present under%EVID%\EFI-ubuntu-before. If any backup gate is unmet, do not delete the entry or directory. -
Delete only the Ubuntu firmware object from an elevated Command Prompt:
bcdedit /delete {<ubuntu-firmware-GUID>} bcdedit /enum firmware /vIn PowerShell, quote the braces. Never substitute
{bootmgr}or{fwbootmgr}. -
Remove only the confirmed stale directory:
rd /s /q S:\EFI\ubuntu dir /a S:\EFI -
Confirm
S:\EFI\Microsoftstill exists and was not changed. -
Remove the temporary mount point:
mountvol S: /d -
Restart and verify Windows Boot Manager is the intended remaining entry.
Branch E — Repair an EFI file-system defect before removing the stale directory
Use only when Ubuntu is intentionally being removed, the exact ESP is proven, readable EFI content is backed up externally, and read-only CHKDSK reports a defect or file operations return corruption errors.
-
Back up every readable EFI vendor directory, not only Ubuntu, to a destination that must not already exist. Reset the attempt variables to the exact recorded attempt and validate its marker first:
set "ATTEMPT=<exact-recorded-Attempt-NN>" set "EVID=X:\FixBackup\FIX-072\%ATTEMPT%" findstr /x /l /c:"FIX-072" "%EVID%\attempt-marker.txt" >nul || (echo STOP: wrong attempt directory & exit /b 1) findstr /x /l /c:"EVID=%EVID%" "%EVID%\attempt-marker.txt" >nul || (echo STOP: attempt path does not match marker & exit /b 1) if exist "%EVID%\EFI-all-before\" (echo STOP: stale backup destination & exit /b 1) md "%EVID%\EFI-all-before" || exit /b 1 robocopy S:\EFI "%EVID%\EFI-all-before" /E /COPY:DAT /R:0 /W:0 set "RC_EFI_ALL_BACKUP=%ERRORLEVEL%" echo Robocopy exit code: %RC_EFI_ALL_BACKUP% > "%EVID%\EFI-all-backup-result.txt" if %RC_EFI_ALL_BACKUP% GEQ 8 (echo STOP: complete EFI backup failed & exit /b 1) powershell -NoProfile -Command "(Get-ChildItem -LiteralPath 'S:\EFI' -File -Recurse | Measure-Object).Count" > "%EVID%\EFI-all-source-file-count.txt" powershell -NoProfile -Command "(Get-ChildItem -LiteralPath (Join-Path $env:EVID 'EFI-all-before') -File -Recurse | Measure-Object).Count" > "%EVID%\EFI-all-backup-file-count.txt" fc /b "%EVID%\EFI-all-source-file-count.txt" "%EVID%\EFI-all-backup-file-count.txt" >nul || (echo STOP: complete EFI backup count differs from source & exit /b 1) for /f "usebackq delims=" %C in ("%EVID%\EFI-all-backup-file-count.txt") do set "EFI_ALL_BACKUP_FILES=%C" if "%EFI_ALL_BACKUP_FILES%"=="0" (echo STOP: complete EFI backup contains no files & exit /b 1) dir /s /a S:\EFI dir /s /a "%EVID%\EFI-all-before"Require a Robocopy exit code from 0 through 7, zero failed files, matching expected file counts, and readable copies of
EFI\Microsoftplus every other required loader directory. Stop beforechkdsk /fif the external copy is incomplete or cannot be opened. -
Run corrective CHKDSK:
chkdsk S: /f -
Record the complete output and every correction. If CHKDSK reports I/O errors or cannot complete, stop; do not continue deletion.
-
Reinspect the Microsoft and Ubuntu directories:
dir /a S:\EFI\Microsoft\Boot dir /a S:\EFI\ubuntu -
If the Windows loader directory is intact and the stale Ubuntu directory is now readable, perform Branch D.
-
If Windows loader files are missing or damaged, stop and restore them from a validated backup or use a separate Windows EFI boot-file repair procedure before rebooting.
Expected results and branches
- Ubuntu entry exists and boots: only boot order needs adjustment; do not reinstall.
- Ubuntu files exist but NVRAM entry is absent: recreate the entry with
efibootmgr; do not rewrite Windows files. - Ubuntu root is intact but EFI/GRUB files are missing: use the scoped chroot reinstall and verify both operating systems.
- Ubuntu was removed and the directory is healthy: delete only the exact Ubuntu firmware object and
EFI\ubuntubackup-backed directory. - Deletion reports error 2, 145, or 1392 and CHKDSK finds errors: back up the ESP, repair the file system, reinspect, then remove only the stale directory.
- Windows Boot Manager fails after any change: stop further changes, use the one-time menu or recovery media, and route by the exact Recovery code.
- Multiple ESPs or disks remain ambiguous: make no write; escalate for disk-to-loader mapping.
Do not do this
- Do not format, delete, resize, convert, clean, or recreate the EFI System Partition.
- Do not delete
EFI\Microsoft,bootmgfw.efi,BCD,EFI\Boot, or an unidentified vendor directory. - Do not copy or rename a Linux loader over Microsoft's
bootmgfw.efi. - Do not use
bcdedit /deleteon{bootmgr},{fwbootmgr}, or a GUID identified only by its position. - Do not mount the Ubuntu ESP over
/mntafter mounting the Ubuntu root there; the ESP belongs at/mnt/boot/efifor the conventional layout. - Do not run GRUB installation commands with example
/dev/sdaor/dev/nvme0n1p1values unless they match the detected machine. - Do not boot the live media in legacy mode and then force EFI-variable commands.
- Do not run
chkdsk /fon an ESP before backing up all readable loader content. - Do not remove Ubuntu boot artifacts while Linux data recovery is still desired.
- Do not change Secure Boot merely to avoid a signed-loader error.
Rollback
If boot order alone was changed
Return the original entry to its recorded position using firmware setup or efibootmgr -o <recorded-order> from a UEFI Ubuntu session. Use only the order preserved before the change.
If the Ubuntu NVRAM entry was deleted
A Windows BCD export may not restore the firmware variable. Boot Ubuntu media in UEFI mode and recreate the entry with Branch B, using the verified ESP, disk, partition number, and loader path.
If EFI\ubuntu was deleted
-
Mount the same verified ESP as
S:. -
Reset
ATTEMPTandEVIDto the exact attempt that backed up and deleted this directory. Validate the attempt marker and the two saved pre-deletion file counts before invoking Robocopy. Do not choose a path because it is newest:set "ATTEMPT=<exact-recorded-Attempt-NN>" set "EVID=X:\FixBackup\FIX-072\%ATTEMPT%" findstr /x /l /c:"FIX-072" "%EVID%\attempt-marker.txt" >nul || (echo STOP: wrong attempt directory & exit /b 1) findstr /x /l /c:"EVID=%EVID%" "%EVID%\attempt-marker.txt" >nul || (echo STOP: attempt path does not match marker & exit /b 1) if not exist "%EVID%\EFI-ubuntu-before\" (echo STOP: recorded Ubuntu EFI backup is missing & exit /b 1) if not exist "%EVID%\EFI-ubuntu-source-file-count.txt" (echo STOP: source count is missing & exit /b 1) if not exist "%EVID%\EFI-ubuntu-backup-file-count.txt" (echo STOP: backup count is missing & exit /b 1) fc /b "%EVID%\EFI-ubuntu-source-file-count.txt" "%EVID%\EFI-ubuntu-backup-file-count.txt" >nul || (echo STOP: saved pre-deletion counts differ & exit /b 1) for /f "usebackq delims=" %C in ("%EVID%\EFI-ubuntu-backup-file-count.txt") do set "EXPECTED_UBUNTU_FILES=%C" if "%EXPECTED_UBUNTU_FILES%"=="0" (echo STOP: saved backup count is zero & exit /b 1) if exist S:\EFI\ubuntu\ (echo STOP: restore destination already exists; inspect it without merging & exit /b 1) robocopy "%EVID%\EFI-ubuntu-before" S:\EFI\ubuntu /E /COPY:DAT /R:0 /W:0 set "RC_UBUNTU_RESTORE=%ERRORLEVEL%" echo Robocopy exit code: %RC_UBUNTU_RESTORE% > "%EVID%\EFI-ubuntu-restore-result.txt" if %RC_UBUNTU_RESTORE% GEQ 8 (echo STOP: Ubuntu EFI restore failed & exit /b 1) -
Verify the restored file count and every loader file that existed in the backup before recreating NVRAM state:
powershell -NoProfile -Command "(Get-ChildItem -LiteralPath 'S:\EFI\ubuntu' -File -Recurse | Measure-Object).Count" > "%EVID%\EFI-ubuntu-restored-file-count.txt" fc /b "%EVID%\EFI-ubuntu-backup-file-count.txt" "%EVID%\EFI-ubuntu-restored-file-count.txt" >nul || (echo STOP: restored file count differs from backup & exit /b 1) if exist "%EVID%\EFI-ubuntu-before\shimx64.efi" if not exist S:\EFI\ubuntu\shimx64.efi (echo STOP: shimx64.efi was not restored & exit /b 1) if exist "%EVID%\EFI-ubuntu-before\grubx64.efi" if not exist S:\EFI\ubuntu\grubx64.efi (echo STOP: grubx64.efi was not restored & exit /b 1) if exist "%EVID%\EFI-ubuntu-before\mmx64.efi" if not exist S:\EFI\ubuntu\mmx64.efi (echo STOP: mmx64.efi was not restored & exit /b 1) if exist "%EVID%\EFI-ubuntu-before\grub.cfg" if not exist S:\EFI\ubuntu\grub.cfg (echo STOP: grub.cfg was not restored & exit /b 1) robocopy "%EVID%\EFI-ubuntu-before" S:\EFI\ubuntu /E /L /COPY:DAT /R:0 /W:0 /NJH /NJS /NP set "RC_UBUNTU_COMPARE=%ERRORLEVEL%" if not "%RC_UBUNTU_COMPARE%"=="0" (echo STOP: restored Ubuntu EFI tree still differs from the recorded backup & exit /b 1) dir /s /a "%EVID%\EFI-ubuntu-before" dir /s /a S:\EFI\ubuntuRequire the saved Robocopy result to be 0 through 7, identical nonzero counts, and all files expected from the recorded backup to be present and readable. An exit code of 8 or higher is failure, even if some files appeared.
-
Only after those checks pass, recreate the firmware entry from Ubuntu media with Branch B using this same recorded attempt. If any restored-file check fails, do not create an NVRAM entry pointing to an incomplete loader tree.
If GRUB reinstall made the situation worse
Use the one-time firmware menu to start Windows Boot Manager. Preserve the failed GRUB output. Mount the same verified ESP and external device, compare the current EFI tree to the exact recorded attempt's BranchC-GRUB/EFI-all-before backup, and restore only the files changed by the GRUB branch. Do not overwrite newer unrelated vendor files and do not delete Windows files. If the exact changed-file set cannot be established, use the exact Ubuntu release's recovery procedure instead of copying the entire tree blindly.
If CHKDSK changed the ESP
There is no byte-for-byte command rollback for file-system corrections. Restore missing loader files from the external EFI backup and verify both boot paths before normal use. If Windows files are affected, use a separate BCDBoot/EFI repair procedure with detected Windows and ESP volumes.
Verification
Restoration verification
efibootmgr -vshows one intended Ubuntu entry pointing to the verified\EFI\ubuntu\shimx64.efior documented loader.- The one-time boot menu starts Ubuntu successfully.
- Ubuntu reaches a usable session and mounts its expected root and ESP.
- Windows Boot Manager independently starts Windows successfully.
- Three cold starts preserve the intended default and one-time choices.
update-grubcompleted without an unresolved error. If Windows is not listed in GRUB, verify that it remains independently bootable through firmware rather than editing GRUB blindly.
Removal verification
bcdedit /enum firmware /vno longer lists the exact stale Ubuntu object.- The verified ESP no longer contains
EFI\ubuntu, whileEFI\Microsoft\Bootremains intact. - Windows Boot Manager starts Windows three times.
- The firmware one-time menu no longer displays the stale Ubuntu choice after a full power cycle.
- Disk Management/DiskPart shows the same partitions and types as before; no layout change occurred.
- The external EFI backup and before/after firmware listings are retained with the case record.
Confidence and stop conditions
Bounded confidence: approximately 80% for the narrowly scoped UEFI Ubuntu cases that pass all mapping gates. One discussion reported restored dual-boot access after Ubuntu/GRUB recovery; another affected participant reported that repairing EFI file-system metadata allowed removal of an unreadable stale Ubuntu directory and that firmware no longer showed the entry. Microsoft documents mountvol, BCDEdit enumeration/deletion, and UEFI BCD behavior; Ubuntu documents GRUB reinstall concepts. The project has not independently reproduced these exact systems, and the source recovery commands required safety correction and clearer mount points before publication.
Stop immediately if the goal is unclear, the Linux root or ESP cannot be identified, multiple ESPs cannot be mapped, UEFI variables are unavailable, the layout uses LUKS/LVM/Btrfs/RAID or a separate /boot that is not mapped, Secure Boot rejects the loader, CHKDSK reports I/O failure, Windows loader files change unexpectedly, or either operating system contains unbacked-up data.