LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 02-02-2007, 01:51 PM   #1
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
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?
 
Old 02-02-2007, 02:04 PM   #2
pljvaldez
Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092

Rep: Reputation: 269Reputation: 269Reputation: 269
From the live CD do
Code:
mkdir /mnt/temp
mount /dev/hda2 /mnt/temp
chroot /mnt/temp
grub-install /dev/hda
 
Old 02-02-2007, 02:41 PM   #3
inspiron_Droid
Member
 
Registered: Dec 2006
Distribution: Debian (Wheeze)
Posts: 391

Rep: Reputation: Disabled
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.
 
Old 02-02-2007, 03:49 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
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.
 
Old 02-02-2007, 05:34 PM   #5
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
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?

Last edited by saikee; 02-02-2007 at 05:35 PM.
 
Old 02-02-2007, 07:19 PM   #6
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
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.
 
Old 02-02-2007, 07:41 PM   #7
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
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
 
Old 02-02-2007, 07:45 PM   #8
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
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
 
Old 02-02-2007, 08:02 PM   #9
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
By the way, I have followed both posts exactly as they stated; I didn't run grub-install within grub.
 
Old 02-02-2007, 08:21 PM   #10
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
Any idea how I can add ubuntu entry to windows boot loader so that I can boot my ubunu?
 
Old 02-02-2007, 08:28 PM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
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
 
Old 02-02-2007, 10:22 PM   #12
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
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
 
Old 02-02-2007, 11:06 PM   #13
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
i got it working by editing grub menu when booting. instead of hda2 it was written hda3 and so on. Thanks for help
 
Old 02-03-2007, 04:20 AM   #14
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add Windows XP to Grub boot loader? LUB997 Linux - Software 29 10-17-2009 12:11 PM
GRUB boot loader blocking windows boot julienroger Linux - Newbie 3 10-12-2004 02:11 PM
GRUB boot loader problem with Windows 2000 bukich Linux - General 1 06-11-2004 07:42 AM
GRUB boot loader on TurboLinux doesn't detect Windows shantanun Linux - Newbie 2 02-18-2004 08:49 AM
How to add a boot record which used to startup windows under my Grub boot loader? yunxiang Linux - Newbie 6 02-01-2003 03:22 AM


All times are GMT -5. The time now is 03:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration