How to recover the Windows 10 MBR after w Linux install?
I had an initial installation of Windows 10 I then installed Linux in dual-boot, with grub managing the boot choices (Ubuntu, Windows 10). Everything works as expected. Is there a way to recover the Windows Boot Manager so that it is the one used to decide upon the boot choices (and boot Windows by default)? I would then look at extending it to boot Ubuntu. Note: I am not looking at simply setting Windows 10 as the boot default via grub — I would like ultimately to swap grub with the Windows Boot Manager.
2 Answers 2
You need to understand something first. Windows 10 doesn’t use the master boot sector by default. Neither do modern distributions of Linux. In any normal circumstance the Grub 2 bootloader does not overwrite the Windows 10 bootloader. They can coexist perfectly fine on the EFI partition. In which case it is your BIOS’s boot order that decides which bootloader is launched.
I’m afraid Keltari’s answer presumes you are using a MBR partition table. which is rather unlikely. In fairness, your question seems to make the same assumption. Thus, before doing anything else, I suggest you check your boot options in your BIOS and see if Windows 10 isn’t still listed as an option. If not. then yeah. bad things happened.
There are a few circumstances where access to the Windows 10 bootloader would be cut off.
- Window 10 was installed in MBR mode. Then Linux was installed.
- If Windows 10 came on your computer from the manufacturer, then this is not the case.
- This would only reasonably happen in two ways.
- You installed Windows 10 as an upgrade to a previous windows install which was in turn installed on top of a previous windows install going back to at least Windows Vista. If you’ve done this, you really need to reinstall Windows 10 fresh anyway.
- The hard drive was configured for MBR/DOS style partitions (instead of GPT) and you chose not to wipe the drive off and start fresh when Windows 10 was installed. This would typically happen if the hard drive was migrated from an older computer to your current one.
In the case of #1 or #2:
You will need to restore the bootloader from the Windows 10 installation disk. If your computer didn’t come with a Windows 10 installation disk, then you will need to acquire one. A Windows 10 ISO can be legitimately downloaded from the Microsoft website. You can then use the burning utilities in Linux to apply the ISO image to a blank DVD-R. If your computer is in warranty you may be able to acquire a Windows 10 install dvd from your manufacturer. but make sure you are clear that you want the Windows 10 installation disk not system recovery disks.
Boot from the Windows 10 DVD (either via «legacy» boot or «UEFI» boot. for MBR partition tables or GTP partition tables respectively). When you get to the Installation welcome screen where is says Install Now go ahead and ignore the Install Now button and click on Repair your computer instead.
- From the Choose An Option menu select Troubleshoot
- From the Troubleshoot menu select Advanced
- From the Advanced menu select Startup Repair
You then may or may not be asked for a user and password to login. This is a good thing if it does show up. it means Windows Repair definitely found your Windows 10 installation. If it doesn’t show up it’s no big deal. Either way it should begin attempting various automated diagnostic and repair routines. In a perfect world, this will restore the Windows 10 bootloader.
If your system is using MBR then it will replace the Grub 2 bootloader. If your system is still using EFI boot it will not remove the Grub 2 bootloader. it will install itself along side it. In the latter case you will still likely need to enter your BIOS and change the boot order so that your BIOS starts the Windows 10 bootloader.
If that does not work then the solution is, invariably, going to be much more involved. You can either take your computer to a professional tech or wipe it off and reinstall Windows 10 from scratch.
In the case of #3:
You need to be extra sure this is what happened before you convert to GPT. You also need to backup any important data first, as this is the realm of evil monsters named Data Loss and Corruption. Take your time with this. it takes just two wrong keystrokes to wipe out your data.
First you need to identify the device name of the disk drive. Find and open your distro’s terminal app. It’s probably called something like xTerm or gTerm. Once you are at the terminal prompt type lsblk . This will display something like this:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 28.3G 0 disk ├─sda1 8:1 0 953M 0 part /boot ├─sda2 8:2 0 1K 0 part ├─sda3 8:3 0 23.4G 0 part / └─sda5 8:5 0 4G 0 part [SWAP] sdb 8:16 0 149.1G 0 disk └─sdb1 8:17 0 149.1G 0 part /mnt/storage
Find the mount point for / and/or /boot . The mount points correspond to partitions (or some other form of logical division of disk resources). If you look under the Name heading for each mount point you will see that logical disk’s device-name . And if you follow the connecting line to the listing above that with Type disk you find the device-name for the physical disk. The device-name for the physical disk is what we need. It doesn’t matter what it is or whether looks remotely like the one above, just remember it.
Now, on the same terminal type gdisk /dev/device-name where you replace device-name with the one we found using the lsblk command and type /dev/ before it. Given the example above you would type gdisk /dev/sda . If you get an error about permissions or access, you need to run the command as a super user (likely «root»). How that is done also differs from distro to distro. but you can try putting sudo or su in front of the gdisk command. Like sudo gdisk /dev/sda . from here on I’ll assume you use sudo but just substitute the tools appropriate to your distro.
After running gdisk you should see this:
GPT fdisk (gdisk) version 0.6.14 Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present *************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format! *************************************************************** Command (? for help):
This is important. If you do not see the message about invalid GTP and valid MBR stop here. This isn’t the guide for you. Reconsider #1 and #2 instead.
If you do see this message and you are certain Windows 10 was installed in UEFI mode, then press the p key and then press Enter to print out the partition table. You’re looking for a partition with the type EFI System .
If there isn’t one, well. that sucks and things just got a lot less simple. You’ll need to resize your partitions to make room for a new EFI partition then create the EFI partition, format it Fat32 , then set the partition type to EFI System . And then you’ll need to follow the previous section as well. I’m not going to walk you through using something like gdisk to resize partitions. that’s scary stuff at the best of times and I would want to be the one at the keyboard. You can use gui tools like gparted to accomplish it easily and relatively safely, however.
Either way, first you need to convert the partition table back to GPT. Press the w key and then the Enter key to write changes to the hard drive.
This is the point of no return. You should see the following:
Command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed, possibly destroying your data? (Y/N):
Press the y key and then Enter to re-write the partition table. Your data shouldn’t be harmed. If you saw the EFI partition before then you should be able to simply reboot into Windows at this point. If not, you have more work to do.
How to Repair MBR (Windows Boot Loader) From Ubuntu
This simple tutorial shows you how to repair your Windows 7 boot loader (MBR) from Ubuntu dual boot or Ubuntu Live CD / USB. This can be useful if you don’t have a Windows CD or DVD on hand.
To do so, first boot into your Ubuntu system. When you’re in Ubuntu, press Ctrl+Alt+T on your keyboard to open terminal and follow below steps:
1.) First run below command to check your disk:
The output tells you the disk information:
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x016c8108Device Boot Start End Blocks Id System
/dev/sda1 * 63 39054014 19526976 7 HPFS/NTFS/exFAT2.) Now run commnad to install syslinux, which is a suite of lightweight IBM PC MBR bootloaders for starting up computers with the Linux kernel.
sudo apt-get update; sudo apt-get install syslinux
3.) Once installed, you can fix your Windows bootloader by running below command in terminal:
sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda
Replace the startup disk name /dev/sda in the above command according to the output in step 1.
Ji m
I’m a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to remind me outdated tutorial! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee: https://ko-fi.com/ubuntuhandbook1
19 responses to How to Repair MBR (Windows Boot Loader) From Ubuntu
THX Ji…
You saved me a lot of problems!! a bit more complicated in Windows 7 to resolve the MBR I know this is an older post but I do hope you will se this!!Only output I got was: 0+1 records in
0+1 records out
440 bytes (440 B) copied, 0.0406588 s, 10.8 kB/s Is this right? If so, maybe the MBR wasn’t disrupted to begin with?