6

I did a fresh install of ubuntu 11.04, then I installed Windows 7. So I decided to fix the grub after win7 install using the ubuntu 11.04 Live CD.

Disaster:

instead of

$sudo grub-install --boot-directory=/media/uuid/ /dev/sda

I entered

$sudo grub-install --root-directory=/media/uuid/ /dev/sda

Now when my system boots, it stops at the grub console

grub>

My problem is exactly as this one http://aaron-kelley.net/blog/2011/04/grub-prompt-after-upgrade-to-ubuntu-11-04/ but I have not been able to fix my problem. Thanx for your help.

3 Answers 3

8

I never got in trouble by using these instructions:
https://wiki.ubuntu.com/Grub2#Recover

First of all, you must start your system from a live cd. Then

"METHOD 3 - CHROOT

This method of installation uses the chroot command to gain access to the broken system's files. Once the chroot command is issued, the LiveCD treats the broken system's / as its own. Commands run in a chroot environment will affect the broken systems filesystems and not those of the LiveCD.

1) Boot to the LiveCD Desktop (Ubuntu 9.10 or later). Please note that the Live CD must be the same as the system you are fixing - either 32-bit or 64-bit (if not then the chroot will fail).

2) Open a terminal (Applications > Accessories > Terminal).

3) Determine your normal system partition - (the switch is a lowercase "L")

sudo fdisk -l

If you aren't sure, run

df -Th  

Look for the correct disk size and ext3 or ext4 format.

4) Mount your normal system partition:

Substitute the correct partition: sda1, sdb5, etc.

sudo mount /dev/sdXX /mnt  

Example: sudo mount /dev/sda1 /mnt

5) Only if you have a separate boot partition: sdYY is the /boot partition designation (for example sdb3)

sudo mount /dev/sdYY /mnt/boot 

6) Mount the critical virtual filesystems:

sudo mount --bind /dev  /mnt/dev
sudo mount --bind /dev/pts  /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys  /mnt/sys 

7) Chroot into your normal system device:

sudo chroot /mnt 

8) If there is no /boot/grub/grub.cfg or it's not correct, create one using

update-grub 

9) Reinstall GRUB 2:

Substitute the correct device - sda, sdb, etc. Do not specify a partition number.

grub-install /dev/sdX 

10) Verify the install (use the correct device, for example sda. Do not specify a partition):

sudo grub-install --recheck /dev/sdX 

11) Exit chroot: CTRL-D on keyboard

12) Unmount virtual filesystems:

sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys 

13) If you mounted a separate /boot partition:

sudo umount /mnt/boot 

14) Unmount the LiveCD's /usr directory:

sudo umount /mnt/usr 

15) Unmount last device:

sudo umount /mnt 

16) Reboot.

sudo reboot 
"

6
  • I get stuck at the chroot part
    – Starx
    Mar 29, 2012 at 10:15
  • Which errors are showed to you?
    – desgua
    Mar 29, 2012 at 12:07
  • chroot failed to run command /bin/bash exec format error Please help me.
    – Starx
    Mar 29, 2012 at 12:08
  • Are you using a 64bit cd in a 64bit installed system? (or a 32bit cd in a 32bit installed system). Make sure you are not using a 64bit cd in a 32bit installed system neither a 32bit cd in a 64bit installed system.
    – desgua
    Mar 29, 2012 at 20:52
  • Yes I am using 64 bit cd or 64 bit system. Does the version of linux also affect this?
    – Starx
    Mar 30, 2012 at 4:27
3

Here is how you can solve this problem without using a LiveCD:

  1. Search the root disk.

    grub> search -f /vmlinuz -s root

  2. Set root disk.

    grub> root ($root)

  3. Use these commands to find out root disk's information.

    grub> ls -l ($root)

  4. Set linux kernel. There are three ways to do it.

    1. Change the red number with your root disk number. If your root disk is (hd0, msdos1), then use /dev/sda1 grub> linux /vmlinuz root=/dev/sda1
    2. Change red text with your disk label, which can get by using ls -l ($root) grub> linux /vmlinuz root=LABEL=LABEL
    3. Change red text with your disk uuid, which can also get by using ls ($root) grub> linux /vmlinuz root=UUID=UUID
  5. Set ramdisk.

    grub> initrd /initrd.img

  6. Now, you can boot your system.

    grub> boot

  7. When you are logged in, type this command from terminal to fix your grub menu.

    $ sudo update-grub

2

Another way to solve this, using the boot-repair program:

Boot with Ubuntu 11.04 Live CD and open terminal then copy and paste:

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

Then go to Applications -> System -> Boot Repair to run the program.

1
  • 1
    I used this program after several other methods had failed, and it did the trick.
    – belacqua
    Sep 2, 2011 at 2:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .