How do I restore grub after I ran a fixmbr command?

I have deleted a partition which had an incomplete ubuntu install using Windows 7 partition manager.

Other than that I had a different partition with a working ubuntu but when I deleted the partition and restarted the computer I have found out that grub wont let me enter any operating system so I used the fixMbr command in the windows 7 disc and it seems like grub has been gone and when I boot I don't receive a choice of an os but it automaticlly loads windows 7.

So my question is how can I get ubuntu back?


You need to reinstall GRUB onto the working Ubuntu partition. Grab a Ubuntu LiveCD and boot to it.

One you do that, open GParted. We'll use this to discover your hard drive's letter and your Ubuntu partition's number. GParted screenshot

Now, the underlined part at the top is the device we are looking at (my hard drive) where the underlined part inside the table is my Ubuntu partition (it won't be in the exact same place in the partition, look for an ext4 (or ext3 for Ubuntu versions prior to 10.04) partition). We need these two when we go into the terminal.

Next, open Terminal up and type the following in, replace X with the hard drive letter and Y with the partition number (these two are shown inside GParted)

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

So for my example, I'd replace X with a and Y with 4. (these will vary depending on how your partitions are setup, so do not use these unless GParted says that's where your partitions are at)

Let it work and after it finishes, GRUB should show up when you boot your computer up.


Windows tends to remove other OSs if present. Therefore you need to restore GRUB. If your Ubuntu installation ist still present (check with live CD!) you'll be able to boot into Ubuntu again.