How to Fix Windows MBR from Ubuntu

Fix Windows Mbr 00 Featured Image

If you have tried to dual boot your Windows system with Linux, then you have probably encountered some changes that may not be welcome. When installing Linux in this environment, the GRUB bootloader will overwrite the Windows bootloader within the Master Boot Record (MBR).

This is also true in reverse: if you have installed Linux first, then decide to install Windows, the Windows bootloader will overwrite GRUB, and you will find that there is no way to boot into your Linux Desktop.

Lastly, any major change in Windows can also modify your bootloader, rendering it unusable. This is the case with the Anniversary Update in Windows 10 and the Windows 11 upgrade.

Any of these scenarios can be problematic for the new user, but thankfully, with a little patience and care, there are ways to restore the bootloader, and in the process, repair the MBR.


The first step will be to download and create your Linux live CD or USB. Ubuntu is by far the easiest and most accessible distribution to use, although most Linux distributions can be used for this. Using a different computer, browse to the Ubuntu website and download the latest copy that is right for your architecture.

For example, I am downloading the Ubuntu 20.04.4 LTS version for amd64, as my machine is a 64-bit system.

Fix Windows Mbr 04 Ubuntu Lts Download 1

Follow this guide to create a Linux live USB on Windows.

Booting into Ubuntu Live USB

With your live media created, the next steps are to boot your machine into Ubuntu using your computer’s BIOS and select “Ubuntu” from the GRUB menu.

If this fails, you need to make sure that Secure Boot is DISABLED in the BIOS, as Secure Boot will only allow Windows-based operating systems to boot in the machine.

Once the desktop has launched, click the “Try Ubuntu” option to load Ubuntu as a live disk.

Fix Windows Mbr 18 Try Ubuntu

With that done, open the Terminal from the Applications menu located in the bottom-left corner of the screen.

Fix Windows Mbr 06 Terminal Screen

Note: at this point, be aware that you are dealing with your hard disk directly and read through the guide fully before making any changes, otherwise your entire system may become unstable or corrupted.

By far the easiest way to repair the MBR is by using a small utility called “boot-repair” as opposed to working directly in the Terminal.

Method One: Boot Repair Utility

First, you’ll need to add the repository. Type:

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt update
sudo apt install boot-repair

Once installed, find the application within your Applications menu and click to start.

Fix Windows Mbr 15 Boot Repair

Once the utility starts, select the repair type. For most people, this will be the recommended repair.

Fix Windows Mbr 16 Boot Repair Welcome

When the utility finishes, you should be able to boot your system and select either Windows or Linux from the GRUB menu. Running the utility will also let you change or investigate some of the other options above if you require a more complex boot repair. Clicking “Restore MBR” will enable you to use the MBR tab.

Fix Windows Mbr 17 Boot Repair Advanced

If you get stuck, Ubuntu has a guide on their website.

Method Two: Updating Your GRUB Configuration

Another way to fix the MBR is by directly updating your GRUB configuration. To do that, you need to first make sure that the live disk detects your Windows install. From there, run the os-prober utility:

sudo os-prober

This program will check all of the available disks and partitions for any operating system in your machine. It does this by looking for specific boot files or partitions that a typical operating system installation creates.

Fix Windows Mbr 07 Os Prober 1

One important thing to note, however, is that if os-prober did not detect the Windows partition, it is likely that its boot partition is already corrupt.

If that is the case, the preferred option is to reinstall Windows rather than attempt to rebuild its boot partition.

Knowing that, you can recreate the GRUB configuration from the live disk by running this command:

sudo update-grub

This will rebuild the default GRUB configuration and include the Windows boot partition to it again. Once done, you can now reboot your system and test whether GRUB detected your Windows installation.

Method Three: Syslinux

Aside from using the default GRUB tools, you can also use Syslinux to update your bootloader.

To do that, open a terminal as before and type:

sudo apt install syslinux
Fix Windows Mbr 09 Installing Syslinux 1

Next, type the following, remembering to change the drive name “sda” as appropriate:

sudo dd if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/sda
Fix Windows Mbr 11 Dd Syslinux 1

This will write an MBR binary to the first few sectors of the hard disk. Doing this will make sure that any problem with those first few sectors in Windows are fixed. Once done, you can reboot your machine to test if the reconfiguration worked.

Method Four: mbr

You can also use the simpler mbr tool to rebuild the MBR binary. Similar to syslinux, you will need to first install it to your live disk:

sudo apt install mbr

From there, run the following command to reinstall the MBR binary in your Windows partition:

sudo install-mbr -i n -p D -t 0 /dev/sda
Fix Windows Mbr 12 Install Mbr Tool 1

You can now reboot your machine to check whether the installed MBR binary was detected in GRUB.

Method Five: LILO

Lastly, you can also use LILO to fix your Windows’ MBR. Similar to GRUB and syslinux, LILO is also a bootloader program that can update your GRUB configuration. To use it, however, you need to install it to your live disk:

sudo apt install lilo
Fix Windows Mbr 13 Installing Lilo 1

From there, writing an MBR file to your Windows boot partition is extremely simple. To do that, run the following command:

sudo lilo -M /dev/sda mbr

This command will write an MBR binary in the boot partition of the device that you specified. In my case, I am installing the MBR binary in “/dev/sda.” Once done, you can reboot your computer to check whether GRUB detected the newly installed MBR.

Fix Windows Mbr 14 Lilo Fix Mbr 1

Congratulations! You now know five simple ways to rebuild your Windows’ MBR with Ubuntu Linux. If all this talk made you interested in what Linux can offer, check out the best Linux-Libre distributions that you can install today.

Frequently Asked Questions

1. Can I manually edit my GRUB configuration?

Yes. However, updating your GRUB configuration manually can introduce additional errors that you may not expect. Further, any problems that come up in configuring your grub.cfg file can result in the system not seeing any boot files at all.

Knowing that, if you still want to manually configure your grub.cfg, you need to make sure that you know what you are doing and that you have a backup of an unmodified grub.cfg. To do that, run the following command:

sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.old

2. Can I use a different Linux distribution to rescue my system?

Yes! All of the tools that were described in this article are available in most Linux distributions. For example, you can do the same steps to install an MBR file from LILO in an Arch Linux system.

The only difference is that you need to run pacman instead of installing the LILO package through apt:

sudo pacman -S lilo

3. Can I get my files back even if the Windows Boot Partition is corrupted?

Yes! To do that, find the partition in your disk that contains all the Windows data. For example, I used lsblk to find my Windows partition in “/dev/sda2.”

Knowing that, you need to install ntfs-3g. This will allow you to mount the Windows NTFS filesystem in Linux:

sudo apt install ntfs-3g

Once done, you can run the following command to mount the NTFS filesystem to your local filesystem:

sudo ntfs-3g /dev/sda2 /mnt

Finally, get the files from your corrupted Windows partition to a backup drive.

Image credit: Unsplash

Ramces Red
Ramces Red

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox