If Windows won’t boot because the Master Boot Record (MBR) is corrupted or overwritten, you can repair it from an Ubuntu live USB using the grub-install or boot-repair tool. This guide shows you how to restore the Windows bootloader from Ubuntu, whether you need to fix a broken MBR or replace GRUB with the original Windows boot code.
What the MBR Does and Why It Breaks
The Master Boot Record is the first 512 bytes of the hard drive. It contains the partition table and a tiny boot loader that tells the computer where to find the operating system. Windows writes its own boot code here during installation. The MBR can become damaged by a failed update, a power cut during disk writes, or accidentally installing GRUB (the Linux bootloader) over it. When the MBR is wrong, the PC may show “No bootable device”, “Missing operating system”, or simply restart in a loop.
What You Need Before Starting
- An Ubuntu live USB or live CD (any recent version works).
- A PC that can boot from USB (enter BIOS/UEFI with F2, F12, Del, or Esc).
- Backup of important files if the disk is still accessible.
- Patience: the process is safe but requires careful typing.
Step-by-Step: Repair Windows MBR from Ubuntu
- Boot from Ubuntu live USB – Insert the USB, restart, and press the boot menu key. Choose “Try Ubuntu” (not “Install”).
- Open a terminal – Press
Ctrl+Alt+Tor search for “Terminal” in the activities menu. - Identify your Windows disk – Run
sudo fdisk -lorlsblk. Look for the disk that contains the Windows partition (usually/dev/sdaor/dev/nvme0n1). Note the exact device name. - Install the Windows boot code (for BIOS/Legacy systems) – If your PC uses traditional BIOS (not UEFI), run:
sudo apt update sudo apt install lilo sudo lilo -M /dev/sda mbr
This writes standard Windows MBR code to the first sector. Replace
/dev/sdawith your actual disk. - For UEFI systems – Most modern PCs use UEFI with GPT disks. In that case, the MBR isn’t used for booting; instead, the EFI System Partition (ESP) holds the bootloader. To repair Windows UEFI boot, you need to run
boot-repair(see below) or manually reinstall the Windows bootloader from a Windows recovery USB. - Reboot – Remove the USB and restart. Windows should boot normally.
Using Boot-Repair (Easier Alternative)
Boot-Repair is a graphical tool that automates the process. It can fix both MBR and EFI issues. To use it:
- Boot from Ubuntu live USB and connect to the internet.
- Run these commands in a terminal:
sudo add-apt-repository ppa:yannubuntu/boot-repair sudo apt update sudo apt install boot-repair
- Launch Boot-Repair from the applications menu.
- Click “Recommended repair” and follow the prompts. It will detect your Windows installation and restore the bootloader.
Boot-Repair is the safest option for beginners because it handles both BIOS and UEFI systems automatically.
Common Problems and How to Avoid Them
- Wrong disk selected – Double-check with
lsblkthat you are writing to the correct disk. Writing to the wrong disk can destroy data. - UEFI vs BIOS mismatch – If your PC uses UEFI, the MBR repair above won’t work. Use Boot-Repair or a Windows recovery USB.
- Secure Boot enabled – Some systems refuse to boot third-party bootloaders. Temporarily disable Secure Boot in BIOS/UEFI settings, then re-enable after repair.
- Windows partition not visible – If
fdiskdoesn’t show a Windows partition, the disk may be encrypted or the partition table is corrupted. In that case, use TestDisk to recover the partition table first.
Comparison: MBR vs GPT and UEFI vs BIOS
Understanding the difference is crucial. MBR is the old partitioning scheme used with BIOS. It supports up to 2TB disks and four primary partitions. GPT (GUID Partition Table) is the modern replacement, used with UEFI. It supports larger disks and unlimited partitions. If your Windows was installed in UEFI mode, the MBR is not used for booting; the EFI partition contains the bootloader. Repairing the MBR in that case does nothing. To check which mode you have, look at the partition table: if it shows a small FAT32 partition labeled “EFI”, it’s UEFI. If it shows an MBR with a Windows partition, it’s BIOS.
Safety and Backup Tips
- Always back up data before modifying the boot sector. The MBR repair itself is low-risk, but mistakes in partitioning can cause data loss.
- Use a live USB with the same architecture (64-bit for 64-bit Windows) to avoid compatibility issues.
- If you are not comfortable with the command line, use Boot-Repair’s recommended settings.
- After repair, boot into Windows and run
sfc /scannowfrom an admin command prompt to check system files.
Frequently Asked Questions
Will this erase my Ubuntu installation?
No, repairing the MBR only rewrites the boot code in the first sector. It does not touch partitions or files. Your Ubuntu installation remains intact, but you may lose the GRUB menu. You can reinstall GRUB later if you want dual boot.
What if I want to restore GRUB instead of Windows?
If you prefer to boot into Ubuntu and then choose Windows from the GRUB menu, you can reinstall GRUB instead. Boot from Ubuntu live, mount your Ubuntu root partition, and run grub-install /dev/sda followed by update-grub. This will restore the dual-boot menu.
Can I repair the MBR without a live USB?
If you have a Windows recovery drive, you can use the command bootrec /fixmbr from the command prompt. This is the native Windows method. Ubuntu is only needed when you don’t have a Windows installation media.
Why does my PC show “Invalid partition table”?
This error usually means the MBR is corrupted or the partition table is damaged. The steps above will fix the boot code, but if the partition table itself is broken, you may need TestDisk to rebuild it. Run sudo testdisk from Ubuntu live.
Is it safe to use lilo on a modern system?
LILO is an old bootloader, but its -M option only writes the standard MBR code, not the full LILO. It is safe for BIOS systems. For UEFI, avoid it and use Boot-Repair instead.
What if the repair doesn’t work?
If Windows still won’t boot, the issue may be a corrupted boot configuration data (BCD) file. Boot from a Windows recovery USB and run bootrec /rebuildbcd. Alternatively, use Boot-Repair’s “Advanced options” to restore the EFI bootloader.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- How to Factory Reset iPad If You Forgot Password
- Ubuntu in Windows Store: Which Editions Work?
- Secure Guest Account on Windows 11: Step-by-Step
- Stop Outlook From Changing Hyperlink Font
- Hiberfil.sys: What It Is & How to Delete It
- How to Make a Mask on Snapchat: Step-by-Step