Fixing the Windows MBR using a Ubuntu Live CD or USB

This friend of mine had installed Windows and Fedora side by side on his laptop and wanted to remove the Fedora installation. Removing Fedora is quite easy. All you have to do is to go to Disk Management from Windows (Run -> diskmgmt.msc), find the Fedora partitions, delete them and format as new drives.
However, this also removes the MBR of the machine. To restore the MBR, the accepted method is to use a Windows CD. We didn’t have that luxury. Fortunately we had a Ubuntu Live USB in hand.

The method to fix the MBR is:
1. Boot the machine using the Live USB/CD.
2. Install lilo

sudo apt-get install lilo

3. Fix the MBR using lilo using the command:

sudo lilo -M /dev/sda mbr

Works like a charm!

70 responses on “Fixing the Windows MBR using a Ubuntu Live CD or USB

  1. flagstar

    Glad I found this before downloading any hiren or ultimate boot disk… Since my netbook can’t afford a cd to play, only USB is capable…

    Didn’t know repairing through lilo is much more faster and hassle free rather than going through the trouble downloading again…

    Thank you very much!!

  2. Aerial

    THANK YOU SO MUCH! I spent several hours trying to fix my sister’s netbook (trying to use supergrubdisk, creating a repair disc… and none of that worked). But this solution worked perfectly and was so easy! Much appreciated.

  3. charles

    apt-get install lilo gave a warning to run liloconfig (or some such) which i ignored, as i did not want it to install as boot loader. It seemed to work fine to fix the mbr anyway.

  4. Matteo

    1) Clearest explanation;
    2) Shortest procedure;
    2) No need to put Windows on a usb pendrive (which is an annoying job);
    3) Works on laptops with recovery partitions;

    Thank you!

  5. Sajeev Chacko

    thanks a lot. i had terrible problem. my laptop DVD writer failed, it has no USB boot option, the “/” partition got corrupted, not able to network boot. but i could attach its disk to my desktop and give the 2 commands you mentioned and it worked.

    Thanks a lot again

    Sajeev Chacko, New Delhi, India

  6. madval88

    ok i need to try this. in a pretty bad situation. the drive on which windows was installed can’t be read. as a result there are problems in linux (dual booted). for example if i run windows repair disk it won’t even find any windows partition.

    do you think this will help solve the problem?

      1. madval88

        nope. for example when linux (installed) boots it loops on trying to read that partition…and i sometimes need to stop it. and for some reason this corrupts something in linux and i cant access that disk, then again things like apt-get fails – it actually shows some system error.

        i can’t install new copy of linux or windows! only hope right now is fixing something using the live cd.

      2. thameera

        It’s unlikely that trying to FIX the MBR might solve it. Sorry I’m not an expert to give advice on this; if everything else failed, I’d have backed up whatever data possible and done a full format.

  7. Chahat Upreti

    Can you please tell from where to get the Ubuntu Live USB.I have been trying to find it with no luck.
    Please help,Thanks.

      1. Chahat Upreti

        Another problem has occured.I am unable to access internet while installing ubuntu even when my internet cable is attached,please help.

  8. Thomas Post

    Thank you, thank you, thank you. Worked like a charm. I was playing with several Linux OS-s and decided to start over and I cleaned them all out by reformatting all of the partitions, except for the Windows 7 partition and of course I blew away Grub. Thanks again!

  9. Milen

    Thank you very much :) Very useful info, when you migrate from Windows to Linux (and want to keep your windows environment as a virtual machine ;) )

  10. charlie

    i had winxp and win7 installed with a windows dual boot. i decided to install ubuntu over the winxp, thinking i’d get some sort of bootloader in the package (haven’t used any *nix in 3 years) but didn’t, so i installed LILO. i did what i thought i needed to for LILO, but when i boot it gives me nothing. how do i repair/get to my mbr from an ubuntu live usb??

  11. Martin Settle (@elttesitram)

    Thanks so much. Just had to reboot into the Ubuntu live disc a second time because I had deleted the bootable partition, and had not set the boot flag on one of the remaining disks, so Lilo didn’t know what to do. GParted is in Ubuntu, so that was super easy. Once that was set it worked like a dream.

  12. Aditya

    thanks u so so much…really when on the web most of the articles/suggestions use the windows cd to resolve this grub issue….
    UR Solution is like a MAGIC after 2 weeks of struggling.thanks again…:-)

  13. Ryan

    This doesn’t work in my case, can anyone help?
    I ran a .exe which turned my Windows copy into not geniune and also made me not able to boot past the bios (it constantly boots to bios and repeats).
    My files on my harddrive are fine. I have tried this lilo method but the boot problem still exists.

  14. Lis

    You are my hero.

    I still have my Windows 7 Installation disc, but it rejected the system recovery option with the error: “This version of System Recovery Options is not compatible with the version of Windows you are trying to repair”. I found other isos of repair discs for literally every possible version and ruined some DVDs, all to get the same error each time I tried.

    But your method, two commands in the console, worked perfectly. I did get a warning at the end of the lilo install saying I needed to configure it since it was my first install, but I didn’t end up needing to do anything outside of what you specified.

    Thank you for writing this blog post.

      1. Ravi

        Yes, I want to fix MBR on my external HDD.
        I can verify it using lsblk command.

        sda 8:0 0 xxxG 0 disk (This is internal HDD)
        ├─sda1 8:1 0 100M 0 part
        ├─sda2 8:2 0 xxxG 0 part /
        └─sda6 8:6 0 xxxG 0 part
        sr0 11:0 1 1024M 0 rom
        sdb This is my ext hdd (500G)
        └─sdb1 This is my ext hdd

Leave a Reply