Recovering GRUB after installing Windows 7?

  • Possible Duplicate:
    How can I repair GRUB? (How to get Ubuntu back after installing Windows?)

    I installed Windows 7 after it crashed, and now I am unable to boot Ubuntu. Ubuntu partitions are still there. I tried using Boot-Repair, but it didn't work!

    You can simply use Ubuntu CD itself. Read through as it is already answered there.

  • You can re-install grub in the Master Boot Record using the LiveCD for you distribution version,

    It goes like this:

    • Boot from LiveCD ⋯ please try to use a LiveCD that has the same version of Grub2 as the installed version

    • Mount the root of the installed Ubuntu at /mnt

    • Change root

    • Update grub

    • Install grub

    • Reboot

    The above steps are from near the bottom of the Ubuntu Community Documentation of Grub2

    After booting from the liveCD ( select "Try Ubuntu" on the opening screen)

    Then start up a terminal (dash, type-in terminal, … )…

    • It may be easier to open this web page while running LiveCD. Firefox should allow you to do this.

    Type in the terminal sudo fdisk -l - and enter your password if asked. That's a lower case L. Find the installed Ubuntu partitions, (from mine with other disks snipped ― here):

    [email protected]:~$sudo fdisk -l
    Disk /dev/sde: 300.1 GB, 300089646592 bytes
    255 heads, 63 sectors/track, 36483 cylinders, total 586112591 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xc3f5ebeb
    Device    Boot      Start         End      Blocks   Id  System
    /dev/sde2       138464296   586110975   223823340    5  Extended
    /dev/sde3   *        2048   138463231    69230592   83  Linux
    /dev/sde5       138464298   313460279    87497991    7  HPFS/NTFS/exFAT
    /dev/sde6       313460736   317650943     2095104   82  Linux swap / Solaris
    /dev/sde7       317652992   581922815   132134912   83  Linux
    /dev/sde8       581924864   586110975     2093056   82  Linux swap / Solaris
    Partition table entries are not in disk order

    Find your Linux installation (Id=83, System=Linux0 then type in

    sudo mount /dev/sde3 /mnt

    but use your partition instead of /dev/sde3(my root partition is sde3, sde7 is my home partition).

    This is assuming that you do not have a separate /boot partition. If you do, you will need to also mount it by typing

    sudo mount /dev/sd·· /mnt/boot

    where sd·· is the partition where you installed the separate boot directory.

    ls /mnt - just checking to see if I got it right:

    [email protected]:~$ sudo mount /dev/sde3 /mnt
    [email protected]:~$ ls /mnt
    bin   cdrom  etc   initrd.img      lib         media  opt   root  sbin     srv  tmp  var      vmlinuz.old
    boot  dev    home  initrd.img.old  lost+found  mnt    proc  run   selinux  sys  usr  vmlinuz

    You should test to see if the boot directory is properly installed. Type in ls /mnt/boot and if it is empty, the boot directory is not installed. It should look something like this:

    [email protected]:~$ ls /boot
    abi-2.6.35-30-generic     initrd.img-2.6.35-30-generic
    abi-2.6.35-31-generic     initrd.img-2.6.35-31-generic  vmcoreinfo-2.6.35-30-generic
    config-2.6.35-30-generic  memtest86+.bin                vmcoreinfo-2.6.35-31-generic
    config-2.6.35-31-generic  memtest86+_multiboot.bin      vmlinuz-2.6.35-30-generic
    grub              vmlinuz-2.6.35-31-generic


    for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i; done
    sudo chroot /mnt #change the root
    sudo update-grub # now update grub


    [email protected]:~$ sudo for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i; done
    [email protected]:~$ sudo chroot /mnt
    [email protected]:~$ sudo update-grub
    Generating grub.cfg ...
    Found linux image: /boot/vmlinuz-3.0.0-13-generic
    Found initrd image: /boot/initrd.img-3.0.0-13-generic
    Found linux image: /boot/vmlinuz-3.0.0-12-generic
    Found initrd image: /boot/initrd.img-3.0.0-12-generic
    Found memtest86+ image: /boot/memtest86+.bin
    Found Microsoft Windows XP Professional on /dev/sdc1

    Now to re-install grub in the MBR. You will need to know which disk your system boots from, and find it in the fdisk -l listing you have already done. Then type in sudo grub-install /dev/sd replacing sd· with the disk you will boot from.

    [email protected]:~$ sudo grub-install /dev/sd·

    Then type in Crtl-D to exit chroot.

    Then type in sudo for i in /sys /proc /dev/pts /dev; do sudo umount /mnt$i; done - as one line

    [email protected]:~$ sudo for i in /sys /proc /dev/pts /dev; do sudo umount /mnt$i; done

    If you mounted a separate /boot partition, type in sudo umount /mnt/boot

    [email protected]:~$ sudo umount /mnt/boot

    Then type in sudo umount /mnt

    [email protected]:~$ sudo umount /mnt

    Then type in sudo reboot to restart he system (remember to remove the LiveCD).

    [email protected]:~$ sudo reboot

    Hopefully, grub will be installed.

    I just installed Win7 for a friend and had to this. Thanks to askubuntu, I didn't have to try to remember. Yea! askubuntu.

    Worked great, thanks! Just a note, I didn't bother with all the `umount`ing at the end -- ubuntu automatically unmounts filesystems on shutdown. So I just did a `sudo reboot` and everything worked fine.

    You also need to mount the EFI partition for modern installations. `sudo mount /dev/ /mnt/boot/efi`

    Ah, so those for loops of commands are necessary so that we can run chroot /mnt and work safely inside a chroot jail. Nice. All worked for me.

  • Try this...

    To recover grub:

    1. Open the live version.
    2. Open the terminal and run sudo fdisk -l to see where Linux is installed.
    3. Run sudo mount /dev/sdaX /mnt where x is the number you have found Linux word in
    4. Run sudo grub-install --root-directory=/mnt /dev/sda to install grub.
    5. Run sudo update-grub to update grub and if this command didn't work run it after rebooting.
    6. Reboot.

    You saved my life... The --root-directory was just ehat I needed

    +1 very short and quick solution. It worked great.

    Still works, for Ubuntu 16.04 and Windows 7

    I have problem in step 5. May you explain more? I get this `usr/sbin/grub-probe: error: faild to get canonical path of 'aufs `

    @user145959 as i said if you have errors you can run this command after restarting.

    That works, in my case was Ubuntu 18.04 and Windows 7 Ultimate. The `sudo update-grub` didn't work for me even after rebooting. Grub worked fine though, thanks a lot for this solution.

    Worked for me after Manjaro Architect installer installed everything *except* grub. I skipped step 5.

  • Boot-Repair is a simple tool to repair frequent boot issues you may encounter in Ubuntu like when you can't boot Ubuntu after installing Windows or another Linux distribution, or when you can't boot Windows after installing Ubuntu, or when GRUB is not displayed anymore, some upgrade breaks GRUB, etc.

    enter image description here

    Remark: this can also be performed from a live-CD or live-USB.

    Either add ‘ppa:yannubuntu/boot-repair’ to your Software Sources via the Software Centre or, for speeds-sake, add it using a new Terminal session:

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

    Boot-Repair can be installed & used from any Ubuntu session (normal session, or live-CD, or live-USB). PPA packages are available for Ubuntu 10.04, 10.10, 11.04, 11.10, 12.04 and 12.10. source

    did not work on 64-bit ubuntu CD - used grub install method instead

  • After installing Windows 7, Windows bootloader has overridden the MBR.

    To fix this you can install a program 'EasyBCD' in Windows

    Follow these steps to restore GRUB when after installing EasyBCD:

    1. Launch the program and select ADD NEW ENTRY from the EasyBCD Toolbox

    2. Select the 'Linux/BSD' from the operating systems column

    3. Choose GRUB (Legacy) under type and Click on the ADD ENTRY icon

    4. Choose YES to the restart prompt

    5. GRUB will be displayed after the restart which will detect the Ubuntu partition for you to be able to boot into Ubuntu


    Download link:

    I tried EasyBCD and it did what I wanted. After I reinstalled win7, I lost access to grub. With EasyBCD, I was able to boot Linux to restore my original grub via update-grub2 and then grub-install /dev/sda.

  • Boot-Repair works:

    • I had Windows XP and Ubuntu on my PC.
    • I installed Windows 7 which resulted in new boot loader without Ubuntu.
    • I installed Boot-Repair with the startup disc and GRUB was updated along with Windows 7 and Windows XP.
  • One nuance to be careful about - the instructions say to check if you have a separate boot partition, and if so then do sudo mount /dev/sd·· /mnt/boot. I got confused here - I did have a boot partition that was not my Linux, it was my base partition (/sda0). So I did that command, and ended up getting a grub menu that only showed my Windows boot. I re-ran the procedure without the doing the sudo mount /dev/sd·· /mnt/boot and it worked beautifully - my old GRUB menu was back, with all the Linux options as well as Windows. The instructions are only referring to a separate Linux boot partition, not for the case where your boot partition is not Linux.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM