I can't boot to Ubuntu after installing Windows 7

27,461

Solution 1

You need to boot off the Ubuntu CD and re-install the grub boot loader.

You should really have installed windows first, then Linux afterwards, and it would have picked up your windows installation automatically and added it to the boot loader.

First you will need an Ubuntu Live CD. If you installed Ubuntu from CD then you should already have one. Make sure that the version you have on CD is the same as the version you are running on your computer.

Once you have your CD, and have booted off it, select the "Try Ubuntu" (or similar) icon. This will place you in a very familiar Ubuntu desktop environment.

Next you have to identify which partition is your boot partition.

Go to the Places menus at the top of the screen and mount any filesystems listed there (by clicking on them). The filesystem that opens up and has files similar to this list is the boot filesystem:

config-2.6.18-3-686      initrd.img-2.6.18-3-686.bak  System.map-2.6.18-3-686
grub                     lost+found                   vmlinuz-2.6.18-3-686
initrd.img-2.6.18-3-686  memtest86+.bin

The numbers don't matter, just the names. If you see such things as bin, usr, lib etc then you have the wrong filesystem.

Make a note of the filesystem name (in the top of the window).

Next you need to open a terminal window, so go to the Applications menu and select Accessories then Terminal.

In the terminal type:

$ mount

and look for the line that contains the name of the filesystem that you are interested in. That line will be prefixed by /dev/<something> where is along the lines of sda2, hda1 etc. This is the device name of the boot partition.

Now we are ready to replace the master boot record with Grub.

In this example I assume your boot device is /dev/sda2 and your filesystem is /media/0d104aff-ec8c-44c8-b811-92b993823444 - replace these with your own filesystem details.

$ sudo grub-install --root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444 /dev/sda

Note you miss out the 2 from the device name. You want to reference the entire device, and not just the boot partition. The --root-directory option specifies which partition contains the boot data.

If any warnings appear try modifying the command to this:

$ sudo grub-install --root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444 /dev/sda --recheck

If it all worked you should see this:

Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(hd0)   /dev/sda

You can now reboot the computer and you should have your Grub menu back.

Solution 2

I've written instructions to solve this problem here, because I faced the same situation.

Here's a short summary of the steps:

  1. Insert Ubuntu Live CD into CD drive and boot from it

  2. Identify Ubuntu installation partition from sudo fdisk -l

  3. Mount the Ubuntu partition drive with sudo mount /dev/sdXX /mnt

  4. Mount other partitions also to corresponding directory

  5. Install GRUB boot loader with sudo grub-install --root-directory=/mnt /dev/sda

  6. Unmount and restart

Solution 3

From the Ubuntu Site: https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows

Using the Ubuntu CD (Recommended)

The graphical way:

1. Insert your Ubuntu CD, reboot your computer and set it to boot from CD in the BIOS and boot into a live session. You can also use a LiveUSB if you have created one in the past.

2. Install and run Boot-Repair - - I needed to use the following command to get it to work:

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

3. Click "Recommended Repair".

4. Now reboot your system. The usual GRUB boot menu should appear. If it does not, hold Left Shift while booting. You will be able to choose between Ubuntu and Windows.

Share:
27,461

Related videos on Youtube

xpect0
Author by

xpect0

Updated on September 17, 2022

Comments

  • xpect0
    xpect0 over 1 year

    I installed Ubuntu 10.04 and it is working properly, but today I installed Windows 7 to another partition, and now I did not get any boot menu and automatically Windows is working fine still.

    Is there any option to get boot menu, or how can I remove Windows 7 and get back to my normal situation?

    • Cole Tobin
      Cole Tobin over 11 years
      That is because Windows uses a proprietary bootloader, not GRUB.
  • jonsca
    jonsca over 11 years
    Could you summarize the key points of the article here in the answer in case the link goes dead?
  • mili
    mili over 11 years
    1-Insert Ubuntu Live CD into CD drive and boot from it, 2-Identify ubuntu installation partition from 'sudo fdisk -l', 3-Mount the Ubuntu partition drive by 'sudo mount /dev/sdXX /mnt', 4-Mount other partitions also to corresponding directory, 5-Install GRUB boot loader by 'sudo grub-install --root-directory=/mnt /dev/sda' 6-Unmount and restart. Refer above link is the best way to understand the each step and above link may work most probably.
  • Admin
    Admin over 11 years
    Please edit your answer instead of adding a comment.
  • iono
    iono about 11 years
    I installed Windows first on my SSD, and then Ubuntu second on a partition on my HDD, and also couldn't boot into Ubuntu. I followed the above steps (even though my filesystem that had the files you mentioned also had /bin etc - probably a very bad idea but I was desperate) and the output returned only the first line of your example: "Installation finished. No error reported". Is that a bad sign?
  • jave.web
    jave.web over 3 years
    I had all linux stuff on a single partition - single filesystem - it contained a "boot" directory that contained "grub" directory, so I've chosen that entire filesystem, also if you have a label on the partition, it mount path can be a "normal" path like /media/xxx/LUBUNTU or something :) If you strungle to find your mount path in mount, try mount | grep /dev/s - to filter only lines containing "/dev/s" which is most probably something you're looking for - but be aware if you are running the Live linux from USB - USB ALSO starts with /dev/sd - that is NOT what you want though!
  • jave.web
    jave.web over 3 years
    THIS DOES NOT ADD WINDOWS TO THE GRUB it only recovers the original Ubuntu grub TO ADD WINDOWS TO GRUB - first run the Ubuntu from the GRUB - in Ubuntu, open terminal and do sudo os-prober then sudo update-grub, wait for it to finish, then reboot as described here: askubuntu.com/a/198875/277898