LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices



Reply
 
Search this Thread
Old 06-09-2008, 05:15 AM   #1
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL 4
Posts: 360

Rep: Reputation: 29
how to reinstall grub


I had Red Hat linux working I had some space on my hard drive I made another LVM partition on that free space. after making the LVMs I could not boot Linux. I get a black screen with just written

grub


I think I lost my bootloader, I rescue my system did fdisk -l removed the boot partition and made it again. i gave the command grub--install

what to do next to make grub.conf file how the process will after that.


thanks in advance

shahz
 
Old 06-09-2008, 12:51 PM   #2
noran01
LQ Newbie
 
Registered: Oct 2007
Posts: 12

Rep: Reputation: 0
If you already ran the grub-install command from rescue mode you should be all set. You might have to specify exactly what disk you want to install grub on (i.e. grub-install /dev/sda1, etc...) if you still experience the black screen.
 
Old 06-12-2008, 11:39 AM   #3
felton57
Member
 
Registered: Aug 2007
Posts: 35

Rep: Reputation: 15
This is what I used to do a grub fix.

Boot up using RHEL4 disk.

Type: linux rescue

Hit OK.

Hit OK.

Clicked NO (for networking)

Hit OK.

At prompt, type: chroot /mnt/sysimage

At prompt, type: grub

At prompt, type: find /boot/grub/stage1 or find /grub/stage1

At prompt, type: root (results or previous step)

example: root (hd0,0)

At prompt, type: setup (hd0)

Note: use results from above, I used what mine was as in the example.

At prompt, type: quit

At prompt, type: exit

At prompt, type: exit

Machine will reboot and grub should be fixed. Make sure you remove disk during reboot.

Hope this is helpful.
 
Old 06-15-2008, 08:23 AM   #4
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL 4
Posts: 360

Original Poster
Rep: Reputation: 29
I will make it more clear for the Gurus and helpers

I installed Red Hat Linux

I have partitions like

/dev/sda1 /boot
/dev/sda2 /root
/dev/sda3 swap


I booted my system with rescue mode

chroot /mnt/sysimage/

fdisk /dev/sda

I delted the boot partition (for my lab purpose)

I made it again the boot partition on /dev/sda1

I again rebooted my system with rescue cd

chroot /mnt/sysimage/

df

and I get the following result

/dev/sda2 /

/dev/sda1 /boot

/dev/sda5 /home

now I want to install the grub next steps please.....

thanks
shahz
 
Old 06-15-2008, 08:50 AM   #5
felton57
Member
 
Registered: Aug 2007
Posts: 35

Rep: Reputation: 15
Here's a good source!

http://www.gnu.org/software/grub/manual/grub.html
 
Old 06-15-2008, 09:11 AM   #6
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL 4
Posts: 360

Original Poster
Rep: Reputation: 29
Well again after some googling I rebooted my system with rescue mode.

and gave the command

grub-install /dev/sda

type grub

grub> find /grub/stage1

(hd0,0)

setup (hd0,0)

checking if "/boot/grub/stage1" exists .... no
checking if "/grub/stage1" exists .... yes
checking if "/grub/stage2" exists .... yes
checking if "/grub/e2fs_stage1_5" exists ... yes
Running "embed /grub/e2fs_stage1_5 (hd,0)" .. failed (this is not fatal)
running "embed /grub/e2fs_stage1_5 (hd0,0) ... failed (this is not fatal)

running "install /grub/stage1 (hd0,0) /grub/stage2 p /grub/grub.conf" ... succeeded

done.

grub> reboot


after rebooting my system I get the again the prompt for grub

grub>

and now I am lost what to do and what I am missing.

thanks
 
Old 06-15-2008, 09:44 AM   #7
Larry Webb
LQ Veteran
 
Registered: Jul 2006
Location: Crystal Beach, Texas
Distribution: Suse for mail +
Posts: 5,100
Blog Entries: 7

Rep: Reputation: 229Reputation: 229Reputation: 229
At the grub prompt try
root (hd0,0)
setup (hd0)
 
Old 06-15-2008, 09:44 AM   #8
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 see that PART of what you did involves the use of "setup" in the GRUB shell. That is the only method I ever use---further, you would not use that AND grub-install. It's one or the other.

To install GRUB, you have to specify where its files are. GRUB files are in /boot/grub, but you have to specify which partition.

Suppose I have the GRUB files---eg the config file, menu.lst---in sda3. ((hd0,2) in GRUB's syntax) And I want GRUB installed in the MBR of sda (hd0). The commands are:

grub (starts the GRUB shell)
root (hd0,2)
setup (hd0)

See also the "booting" link below--it includes a link to the GRUB manual
 
Old 06-16-2008, 04:50 AM   #9
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL 4
Posts: 360

Original Poster
Rep: Reputation: 29
I don't have any file within the /boot partition because I already delted the partition made it again with fdisk. I rescued the system with a bootable cd.

when I df I get the follwing.

/dev/sda2 /
/dev/sda1 /boot
/dev/sda5 /home

when I used the grub command

grub> At the grub prompt try
root (hd0,0)
setup (hd0)

the output says

checking if "/boot/grub/stage1" exists .... no
checking if " /grub/stage1" exists ..... no

Please keep in mind that I don't have any files within /boot partition because I deleted the parition made it again now want to install grub on it.


thanks
 
Old 06-16-2008, 07:39 AM   #10
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 shahz View Post
Please keep in mind that I don't have any files within /boot partition because I deleted the parition made it again now want to install grub on it. thanks
If you have no files in the /boot directory, then you are missing more thatn just GRUB. /boot is where you would find your kernel and various other things.

It seems like re-installing Linux might be the easiest solution.
 
Old 06-16-2008, 08:40 AM   #11
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL 4
Posts: 360

Original Poster
Rep: Reputation: 29
well thanks brother for advising to reinstall but I want to get everything manually as I told before that I formated the /boot partition my self. if there is a hard way let me know I want to do it.


thanks
 
Old 06-17-2008, 07:53 AM   #12
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
You have to install into the /boot directory all of the files normally found there. This includes the Linux kernel, maybe an initrd file, the /grub directory, and a few other things. The only way that I would know what was needed would be to look at a system running RHEL4.
 
Old 06-22-2008, 04:54 AM   #13
shellarchive
Member
 
Registered: Jan 2007
Posts: 50

Rep: Reputation: 15
have you tried copying files stage1, stage2 & stage1_5 from /usr/share/grub/i386-pc into /boot/grub/
also cp vmlinuz (kernel binary) from /usr/src/kernel/2.6. . .
(if vmlinuz is not there try compiling new kernel)
create initrd.img file using mkinitrd command.
then do root(hd0,0)
find /boot/grub/stage1 (this should be able to find stage1 file)
setup(hd0)

Note stage1,1_5,2 initrd image, vmlinuz all are needed to boot the system.



Quote:
Originally Posted by shahz View Post
I don't have any file within the /boot partition because I already delted the partition made it again with fdisk. I rescued the system with a bootable cd.

when I df I get the follwing.

/dev/sda2 /
/dev/sda1 /boot
/dev/sda5 /home

when I used the grub command

grub> At the grub prompt try
root (hd0,0)
setup (hd0)

the output says

checking if "/boot/grub/stage1" exists .... no
checking if " /grub/stage1" exists ..... no

Please keep in mind that I don't have any files within /boot partition because I deleted the parition made it again now want to install grub on it.


thanks

Last edited by shellarchive; 06-22-2008 at 04:55 AM.
 
Old 06-23-2008, 01:10 AM   #14
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL 4
Posts: 360

Original Poster
Rep: Reputation: 29
can I get the full command for making initrd, I have copied all the files from /usr/share/grub...
 
Old 06-23-2008, 02:40 AM   #15
shellarchive
Member
 
Registered: Jan 2007
Posts: 50

Rep: Reputation: 15
mkinitrd /boot/initrd-2.2.5-15.img 2.2.5-15
last argument 2.2.5-15 is the name of linux dir /usr/src/kernels/2.2.5-15/

Also have you got your kernel binary. vmlinux.
you will also need system.map-2.6.22.9 & config-2.6.22.9 file for your kernel.
If you don't have any of these files, then only way is to recompile a new kernel.
you can download latest kernel from www.kernel.org
and then compile using commands
cd /usr/src/kernels/2.6. . .>

make mrproper : will remove any previous installation file
make defconfig : will create makefile with default configuration
make menuconfig: configure any additional options
make modules_install: for installing require modules
make install : will compile kernel using makefile created by make defconfig & menuconfig commands, will also copy vmlinuz kernel, system.map file, config file into /boot dir.

and then create & copy initrd file into /boot.

Your system should boot after this. ! ! !.





Quote:
Originally Posted by shahz View Post
can I get the full command for making initrd, I have copied all the files from /usr/share/grub...
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grub error 17, and wont reinstall using grub-install! chiefreborn Linux - General 6 06-06-2007 11:29 AM
reinstall windows, reinstall GRUB too? leupi Linux - Software 1 05-07-2005 11:50 AM
GRUB Reinstall scripts Linux - Software 1 02-21-2005 07:55 PM
reinstall grub leva Linux - Newbie 1 12-14-2003 02:47 PM
Reinstall GRUB Staticreator Linux - Software 0 08-10-2003 05:14 PM


All times are GMT -5. The time now is 06:57 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