LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Replacing windows boot loader by GRUB (https://www.linuxquestions.org/questions/linux-general-1/replacing-windows-boot-loader-by-grub-525029/)

mohtasham1983 02-02-2007 12:51 PM

Replacing windows boot loader by GRUB
 
Hi,
I have a dual boot ubuntu edgy and win xp. After not using win xp for a long time, it crashes so i was forced to reinstall it and now my GRUB doesn't appear when I boot my computer.

I don't know how I can go to rescue mode in ubuntu, whereas in fedora there was such option. Anyhow, I used ubuntu cd live and loaded windows and I mounted my linux partition used grub-install /dev/hda
but it doesn't recognize it.
my windows partition is in /dev/hda1
file system is in /dev/hda2 and swap is in /dev/hda3

Any idea how to get rid off windows boot loader?

pljvaldez 02-02-2007 01:04 PM

From the live CD do
Code:

mkdir /mnt/temp
mount /dev/hda2 /mnt/temp
chroot /mnt/temp
grub-install /dev/hda


inspiron_Droid 02-02-2007 01:41 PM

You should prabaly use a live cd distribution such as knoppix or Ubuntu to reinstall grunb and grub shold land on the NBR of /dev/hda.

pixellany 02-02-2007 02:49 PM

I prefer the grub shell method.

You say that Linux is on /dev/hda2---I assume that there is no separate partition for /boot.
do this (as root):
Code:

grub
root (hd0,1)  tells grub that "home base" is hda2
setup (hd0)  puts grub in the mbr of hda

This should work from any Linux--liveCD, rescue mode, etc.

saikee 02-02-2007 04:34 PM

Either pljvaldez or pixellany proposal would solve the problem.

The reason the grub-install did not work in Post #1 is because it was not issued "inside" hda2.

pljvaldez proposal is to get "inside" hda2. The method will work for any Live CD because it uses the Live CD kernel in combination with Ubuntu's Bash shell (which has Grub inside).

pixellany proposal achieves the same task from "outside" hda2 and looks simpler but it requires a Live CD having Grub inside in order to invoke a Grub shell.

I am here just to offer an explanation and to make a connection between the two proposals.

Where is the response from the Original Poster?

mohtasham1983 02-02-2007 06:19 PM

Sorry for late reply,
Thank you for your responds, but non of them worked for me.
when I issue command:
root@ubuntu:/# grub-install /dev/hda2

I get the following result

/dev/hda2: Not found or not a block device.

and when I go inside grub program and I write:

root@ubuntu:/# grub-install /dev/hda2

I get following errir:

/dev/hda2: Not found or not a block device.

saikee 02-02-2007 06:41 PM

I don't think you are doing it right.

First of all hda2 is shown up by your Ubuntu after mounting it so it must exist and is a block device.

Secondly I don't think anybody here asking you to do a grub-install in hda2. It is hda or the whole disk which is equivalent to the MBR of hda.

Thirdly when you go inside Grub program "grub-install" doesn't work because it is a Linux script and not a command in a Grub shell.

Obviously my explanation has produced the opposite effect.

Please post here the output of
Code:

fdisk -l

mohtasham1983 02-02-2007 06:45 PM

root@ubuntu:/home/ubuntu# fdisk -l

Disk /dev/hda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1912 15358108+ 7 HPFS/NTFS
/dev/hda2 1913 4736 22683780 83 Linux
/dev/hda3 4737 4864 1028160 82 Linux swap / Solaris

mohtasham1983 02-02-2007 07:02 PM

By the way, I have followed both posts exactly as they stated; I didn't run grub-install within grub.

mohtasham1983 02-02-2007 07:21 PM

Any idea how I can add ubuntu entry to windows boot loader so that I can boot my ubunu?

pixellany 02-02-2007 07:28 PM

Quote:

Originally Posted by mohtasham1983
Any idea how I can add ubuntu entry to windows boot loader so that I can boot my ubunu?

If you look at the links in Saikee's sig, you will find MANY different ways of setting up dual-boot. Also, search here on "dual-boot NTLDR".

You don't say if you tried my grub-shell method

mohtasham1983 02-02-2007 09:22 PM

Your commands work actually. I had a mistype when writing them. Now I have grub back but I am not able to boot it due to following error:
/bin/bash can't access tty

mohtasham1983 02-02-2007 10:06 PM

i got it working by editing grub menu when booting. instead of hda2 it was written hda3 and so on. Thanks for help

saikee 02-03-2007 03:20 AM

I hate to repeat it but it is 10 times harder to get Windows NTLDR to boot a Linux.

Not many users realise that in order for NTLDR to work the Linux must has a working boot loader first so that its first 512 bytes can be copied into Windows "c" because Windows is so lazy or dumb to come out to fetch it from a partition foreign to itself. You then have to find a way to write the boot loader into a NTFS partition, unhide boot.ini to add Linux's entry, hide boot.ini again and it may not even work reliably. If your Linux uses Lilo and you may need to alter Lilo a few times then you will know what I mean by 10 times harder.


All times are GMT -5. The time now is 09:15 PM.