I have a PC that can boot both Ubuntu and Win10, with Win10 pre-installed. While experimenting with bootable USB drives, I mistakenly formatted the Win boot partition on /dev/sda1, which is 524MB in size, causing me to lose access to my Windows system. Grub no longer lists it. Luckily, my user data and recovery partition are still intact. My goal now is to recreate the boot partition so that I can boot into Windows again without affecting the user-data partition.
I have already tried to repair the boot sector using a bootable Win10 USB drive and following a guide, but neither the automated option nor the command prompt option worked. I also attempted to use AOMEI, but encountered a “load driver failed” error message when trying to install it using Wine. Additionally, when trying to execute the “bootrec /fixboot” command prompt option mentioned in the guide, I received a “permission denied” message. I haven’t yet tried copying a boot sector from another working Win10 setup because I don’t have access to one.
Can someone please provide instructions on how to restore the boot sector safely?
Ubuntu and Windows 10 are two of the most popular operating systems in the world. Many people have a dual-boot setup with both of these systems on their machines. However, sometimes accidents happen, and important partitions can get deleted or corrupted. In this blog post, we will discuss how to restore the Windows boot partition when it has been accidentally formatted or corrupted.
Understanding the Boot Partition
Before we dive into the solution, let’s understand what the boot partition is and why it is important. The boot partition is a small partition that contains the bootloader and other necessary files for the operating system to boot. In the case of Windows, the boot partition is usually around 500MB in size and is located at the beginning of the hard drive. If this partition is deleted or corrupted, the operating system will not be able to boot.
Creating a Bootable Windows USB Drive
To restore the Windows boot partition, we will need a bootable Windows USB drive. If you don’t have one, you can create one using the Media Creation Tool from Microsoft. The Media Creation Tool will download the latest version of Windows and create a bootable USB drive that you can use to repair your system.
Once you have created the bootable USB drive, insert it into your computer and boot from it. You may need to change the boot order in your BIOS to make sure that the USB drive is the first device in the boot sequence.
Repairing the Boot Partition
After booting from the USB drive, select the “Repair your computer” option. This will take you to the Windows Recovery Environment. From here, select “Troubleshoot” and then “Advanced options.” Finally, select “Command Prompt.”
In the Command Prompt, type “diskpart” and press Enter. This will open the DiskPart utility. Type “list disk” to see a list of all the disks on your system. Identify the disk that contains the Windows installation and note its number.
Next, type “select disk X” (replace X with the number of the disk that contains Windows) and press Enter. Type “list partition” to see a list of all the partitions on the selected disk. Identify the partition that should be the boot partition (usually the first partition on the disk) and note its number.
Type “select partition X” (replace X with the number of the boot partition) and press Enter. Finally, type “active” and press Enter. This will mark the selected partition as active, which is necessary for the system to boot.
Rebuilding the Boot Sector
Now that we have marked the boot partition as active, we need to rebuild the boot sector. In the Command Prompt, type “bootrec /fixboot” and press Enter. This will fix the boot sector of the selected partition.
If you receive a “permission denied” message, try typing “bootrec /fixboot /nt60 all” instead. This will fix the boot sector of all partitions on the disk.
In conclusion, accidentally formatting or deleting the Windows boot partition can be a nightmare. However, with a bootable Windows USB drive and a little bit of knowledge, it is possible to restore the boot partition and get your system up and running again. Remember to always back up your important data and be careful when experimenting with bootable USB drives.
It sounds like you’ve lost access to your Windows installation due to formatting the Windows boot partition. Here are some steps you can try to restore the Windows boot partition:
- Boot from the Windows 10 installation media (USB or DVD). When you reach the “Windows Setup” screen, press the “Shift+F10” keys to open a Command Prompt window.
- In the Command Prompt window, type the following commands, pressing Enter after each one:
diskpart list disk select disk 0 list partition
This will list the partitions on your computer’s hard drive. Make note of the number of the partition that corresponds to the Windows boot partition (it should be the one with the “System” flag).
- Type the following command to select the Windows boot partition, replacing # with the number of the partition:
select partition #
- Type the following command to set the Windows boot partition as active:
- Type the following command to exit the DiskPart utility:
- Type the following command to repair the Windows boot sector:
- Type the following command to rebuild the Windows boot configuration data:
- Restart your computer and see if you can boot into Windows.
If these steps don’t work, you may need to try a more advanced repair process, such as using the “Repair Your Computer” option in the Windows installation media or using a tool like AOMEI Partition Assistant to recreate the Windows boot partition.
If the steps above don’t help you restore the Windows boot partition and you are unable to boot into Windows, you may need to try more advanced repair techniques or consider reinstalling Windows.
It’s always a good idea to have a backup of your important files and data, in case something like this happens. If you don’t have a backup, you may be able to use data recovery software to try to recover your files from the unformatted partition.
If you decide to reinstall Windows, make sure to back up any important files and data before proceeding. You may also want to consider creating a bootable Windows installation media (USB or DVD) before proceeding, in case you need to repair the Windows boot partition again in the future.
I partially solved the problem by performing the command “bcdboot E:\Windows /s C:” in Windows recovery cmd, where E: represents the User-Partition and C: represents the boot partition. Then, I used rescatux (a Linux OS with grub) to run “update-grub” based on instructions from https://askubuntu.com/questions/145241, which made Windows reappear in the grub menu.
Special thanks to Karel for providing support and helping me understand some basics. Although I can’t recall all the steps I took to make it work, I think I reformatted the boot partition to Fat32, ran bootrec commands (fixmbr, fixboot, and rebuildbcd), and used the bcdboot command with an additional /f UEFI option.
Finally, I reinstalled and updated grub on the sda partition to make my Windows system bootable again.
Although it was a challenging bottleneck, I’m pleased that it eventually worked out.