Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I used to have a dual boot between Ubuntu (lucid) and Windows 7, but wanted to upgrade my Windows to 64 bit, so I installed the new Windows, which naturally wrote over the MBR, and so I attempted to repair it using the following guide: https://help.ubuntu.com/community/Grub2#Reinstalling%20GRUB%202.

I had a lot of trouble following it, but managed to get the system to boot to some grub command line, instead of Windows, which I thought was useful. Then I did something screwy and now when I boot I get a grub rescue command line.

So I follow the instructions on that same page related to rescue mode, but am a bit confused. If I do ls, I get:

(hd0) (hd0,msdos1) (hd1) (hd1,msdos5) (hd1,msdos1)

If I attempt to list the contents of these partitions, the only one that works is (hd1,msdos1), all of the others say "unknown filesystem." Examining the contents of this partition, it appears to contain my Ubuntu home directory.

In any case, I found some combination of commands that do something:

set prefix=(hd1,msdos1)/boot/grub
set root=(hd1,msdos1)
insmod /boot/grub/linux.mod
linux /vmlinuz root=/dev/sdb1 ro
initrd /initrd.img
boot

It then looks like it's going to work, but I find myself in some kind of prompt which calls itself busybox initramfs. I try various things, but can't figure out how to run the command update-grub as recommended.

share|improve this question
add comment

2 Answers 2

This is a quick and simple method of restoring a broken system's GRUB 2 files. The terminal is used for entering commands and the user must know the device name/partition of the installed system (sda1, sdb5, etc). The problem partition is located and mounted from the LiveCD. The files are then copied from the LiveCD libraries to the proper locations and MBR. It requires the least steps and fewer command line entries than the following methods.

  1. Boot to the LiveCD Desktop (Ubuntu 9.10 or later).
  2. Open a terminal by selecting Applications, Accessories, Terminal from the menu bar.
  3. Determine the partition with the Ubuntu installation. The fdisk option "-l" is a lowercase "L".

sudo fdisk -l

If the user isn't sure of the partition, look for one of the appropriate size or formatting.

Running sudo blkid may provide more information to help locate the proper partition, especially if the partitions are labeled. The device/drive is designated by sdX, with X being the device designation. sda is the first device, sdb is the second, etc. For most users the MBR will be installed to sda, the first drive on their system. The partition is designated by the Y. The first partition is 1, the second is 2. Note the devices and partitions are counted differently.

  1. Mount the partition containing the Ubuntu installation.

sudo mount /dev/sdXY /mnt

Example: sudo mount /dev/sda1 Note: If the user has a separate /boot partition, this must be mounted to /mnt/boot

  1. Run the grub-install command as described below. This will reinstall the GRUB 2 files on the mounted partition to the proper location and to the MBR of the designated device.

sudo grub-install --root-directory=/mnt/ /dev/sdX

Example: sudo grub-install --root-directory=/mnt/ /dev/sda 6. Reboot 7. Refresh the GRUB 2 menu with sudo update-grub

reboot...done....

share|improve this answer
add comment

If you want to try automation, there are tools that are supposed to make restoring grub boot sectors and MBR's easier.

Super Grub Disk can be burned to a CD and run separately..

http://www.supergrubdisk.org/

Or you can use it as a part of a wider array of diagnostic and repair tools, such as the Ultimate Boot CD:

http://www.ultimatebootcd.com/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.