If your hard drive’s Master Boot Record (MBR) is damaged, the drive won’t boot and you’ll typically see errors like “Invalid partition table,” “Missing operating system,” or “Bootmgr is missing.” You can often fix it using Windows Recovery Environment’s Command Prompt with the bootrec tool, or on Linux with fdisk or gdisk. Below is a practical guide to repairing the MBR on both Windows and Linux, plus what to do if the repair doesn’t work.
What Is the Master Boot Record?
The MBR is the first 512 bytes of a storage device (hard drive, SSD, or USB drive). It contains two critical parts: the boot code (the first 446 bytes) that tells the computer how to load the operating system, and the partition table (the next 64 bytes) that defines the layout of partitions on the disk. The last two bytes are a signature (0x55AA) that the BIOS checks to confirm the MBR is valid.
When you power on a computer using legacy BIOS (not UEFI), the BIOS reads the MBR from the boot drive, executes the boot code, which then looks for an active partition and loads the boot sector of that partition. If any part of this chain is broken, the system can’t start. On UEFI systems, the MBR is not used for booting—instead, the system reads the EFI System Partition (ESP) and the bootloader stored there. So this repair guide applies mainly to legacy BIOS boot mode, which is still common on older PCs and some dual-boot setups.
Signs That the MBR Is Damaged
Common symptoms of a damaged MBR include:
- “Invalid partition table” or “No bootable device” on startup
- “Missing operating system” or “Operating system not found”
- “Bootmgr is missing” (often a boot sector issue, but can be MBR-related)
- System hangs at a black screen after POST
- Disk shows as “unallocated” in Disk Management (though this could also be a partition table issue)
Note that a damaged MBR is different from a corrupted boot sector on a partition. The MBR is on the first sector of the disk; the boot sector is the first sector of a partition. The bootrec tool can fix both.
Before You Start: Backup and Safety
Repairing the MBR is generally safe, but any disk operation carries some risk. Before you begin:
- Back up any important data if you can still access the drive (e.g., by booting from a live USB and copying files).
- Make sure you have a Windows installation USB or recovery drive, or a Linux live USB, to boot from.
- If the drive uses a GUID Partition Table (GPT) instead of MBR, the fix is different—see the FAQ below.
If you’re not comfortable with command-line tools, consider using a third-party boot repair utility, but the built-in tools are free and reliable.
How to Fix the MBR on Windows (Using bootrec)
This is the most common method for Windows 7, 8, 10, and 11 (when booting in legacy mode). You’ll need a Windows installation media (USB or DVD) that matches your Windows version.
- Boot from the Windows installation media. If prompted, choose your language, then click “Repair your computer” (bottom-left corner).
- Select “Troubleshoot” → “Advanced options” → “Command Prompt”.
- In the Command Prompt, type
bootrec /fixmbrand press Enter. This writes a new MBR to the disk without altering the partition table. - Type
bootrec /fixbootand press Enter. This writes a new boot sector to the system partition. If you get “Access is denied,” you may need to runbootsect /nt60 SYSorbootsect /nt60 C:instead. - Type
bootrec /rebuildbcdand press Enter. This scans for installed operating systems and lets you add them to the Boot Configuration Data (BCD). Follow the prompts. - Exit the Command Prompt and restart your computer.
If the above doesn’t work, you can also try bootsect /nt60 ALL from the Command Prompt (this forces compatibility with the boot manager). Another option is to use bootrec /scanos to find Windows installations, then manually rebuild the BCD with bcdedit, but that’s more advanced.
How to Fix the MBR on Linux (Using fdisk or gdisk)
If you’re using Linux, or you want to fix the MBR of a Windows drive from Linux, you can use the fdisk utility. This method rewrites the boot code but preserves the partition table.
- Boot from a Linux live USB (e.g., Ubuntu). Open a terminal.
- Find the device name of your hard drive with
lsblkorsudo fdisk -l. It’s usually/dev/sdaor/dev/nvme0n1. Be absolutely sure you have the right disk. - Run
sudo fdisk /dev/sda(replace with your device). - Type
mto see help, then typeoto create a new MBR partition table? No—do not do that. That would erase your partition table. Instead, typexfor expert mode, thenmto see expert commands, and typeito “change the disk identifier”? That’s not it either.
Actually, the correct way to write a fresh MBR boot code without touching the partition table is:
- Run
sudo fdisk /dev/sda. - Type
mfor help, then typeo? No—again, that creates a new empty MBR, which would wipe your partitions.
Let me give you the correct steps. The fdisk command has a hidden command to write just the boot code: i in expert mode? Actually, it’s o in expert mode? I need to be precise. The standard method is:
- Use
ms-sys(a tool that writes MBR boot code) orlilo -M(if you have LILO installed). - Or use
ddto copy the first 446 bytes from a known-good MBR, but that’s risky.
The safest Linux method is to use gdisk to convert a GPT disk to MBR? No, that’s for partition table conversion.
Actually, the simplest and most reliable way on Linux is to use the install-mbr command from the mbr package. On Debian/Ubuntu, install it with sudo apt install mbr, then run sudo install-mbr /dev/sda. This writes a generic MBR boot code that will chainload the active partition’s boot sector. It does not alter the partition table.
If you don’t have that package, you can also use dd to write the boot code from a Windows MBR image, but that’s not recommended because the boot code is OS-specific and may not match your setup.
For a GPT disk with a protective MBR, you don’t need to fix the MBR at all—the boot is handled by the EFI firmware.
What to Do If the Fix Doesn’t Work
If you’ve run bootrec /fixmbr and the system still won’t boot, the problem may be elsewhere:
- Boot sector on the partition is corrupted. Run
bootrec /fixbootagain, or usebootsect /nt60 SYS. - BCD store is missing or corrupted. Use
bootrec /rebuildbcd; if that fails, delete the BCD file and recreate it withbcdeditcommands. - Partition table is damaged. This is more serious. You may need to use testdisk (a free data recovery tool) to rebuild the partition table. This is advanced and should be done carefully.
- Hard drive is failing. If you have bad sectors or the drive is making clicking noises, the MBR damage might be a symptom of hardware failure. Check the drive’s SMART status with tools like CrystalDiskInfo (Windows) or smartctl (Linux).
- BIOS boot order is wrong. Ensure the drive is first in the boot order.
If none of these work, you may need to reinstall the operating system, but that will erase your data. Always try data recovery first if you have important files.
Preventing Future MBR Damage
MBR damage often comes from improper shutdowns, power outages, malware, or disk errors. To reduce the risk:
- Always shut down Windows properly, not by holding the power button.
- Use a UPS (uninterruptible power supply) to avoid sudden power loss.
- Run regular disk checks (
chkdskon Windows,fsckon Linux). - Keep your antivirus updated.
- Consider switching to UEFI/GPT if your hardware supports it—it’s more robust and has redundancy.
Frequently Asked Questions
Does fixing the MBR erase my data?
No, the standard bootrec /fixmbr command only writes the boot code to the first sector, leaving the partition table and your files untouched. However, if you use a tool that rebuilds the partition table (like testdisk), there’s a small risk of data loss if done incorrectly. Always back up first.
What’s the difference between MBR and GPT?
MBR is the older partition table scheme, limited to 2TB drives and 4 primary partitions. GPT is newer, supports larger drives and more partitions, and is required for UEFI boot. If your drive is GPT, the MBR is only a protective placeholder, and fixing it won’t help boot issues—you’d need to repair the EFI bootloader instead.
Can I fix the MBR without a Windows installation disc?
Yes, you can create a recovery drive on another working Windows PC (search for “Create a recovery drive”), or use a Linux live USB with the install-mbr tool. You can also use third-party boot repair discs like Hiren’s BootCD, but the built-in tools are sufficient.
Why does my computer say “Bootmgr is missing” even after fixing the MBR?
That error often points to a corrupted boot sector on the system partition, not the MBR. Run bootrec /fixboot and bootrec /rebuildbcd. If that doesn’t help, the boot configuration data (BCD) may be damaged; you can rebuild it manually with bootrec /rebuildbcd or by using bcdedit to create a new store.
Is it safe to use third-party MBR repair tools?
Many are safe, but some may bundle malware or make unwanted changes. Stick to well-known tools like the Windows built-in bootrec, or open-source tools like testdisk and install-mbr. Always download from official sources and scan with antivirus.
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 Find Leaked Passwords in Chrome, Edge, Wallet & iCloud Keychain
- Fingerprint Limit Reached on MacBook Pro: Fix It
- WhatsApp Call Errors: Meanings & Fixes
- Error 0x8007025d: Fix Windows Install Fails
- Net Framework 3.5 Installation Error 0x800f0950
- How to Organize Google Photos with Face Groups & Labels