LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Stuck at grub legacy prompt after boot. (https://www.linuxquestions.org/questions/linux-newbie-8/stuck-at-grub-legacy-prompt-after-boot-945636/)

dgonzalezh 05-17-2012 11:28 PM

Stuck at grub legacy prompt after boot.
 
Hi, I have CentOS 6 installed on my server and accidentally deleted the contents of /boot partition, so I d/loaded a CentOS LiveCD and booted from it.

I chrooted into /mnt/sysimage I created and mount -o bind the lvs that contain /usr and / respectively and I reinstalled grub grubby xen and the kernel with yum reinstall blah... /boot got populated again but /boot/grub/grub.conf was not created so I used one of my other server to mimic it of course changing the sd_LVM_LV= values to suit the other server's, when I reboot 'm stuck at the grub> prompt where I can type commands and I can certainly boot using:

Code:

kernel /vmlinuz
initrd /initramfs.img
boot

The system starts just fine and I can use it normally, but if I reboot, then again stuck at grub's prompt.

Apparently Grub is not reading my grub.conf which *IS* there indeed.

I've read a zillion threads and forums but they take me nowhere.

If anyone can help this n00b, thanks.

ratotopi 05-18-2012 01:07 PM

Do the necessary backup once the server is up then reboot the server with the Redhat installation DVD. Choose the option "install or upgrade an existing system", it should fix your problem if you follow the upgrade properly. Do this at your own risk.

RockDoctor 05-18-2012 02:56 PM

I don't know if this will be of any help, but long ago, I downloaded to my collection of helpful docs, a howto that explains how to restore grub-legacy. Unfortunately, I didn't document the source, so I don't know to whom the credit should go, but it's saved me many, many times. Anyway, heres an example taken from that howto:
Code:

title Red Hat Linux (2.4.18-14)
        root (hd0,1)
        kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ hdc=ide-scsi
        initrd /boot/initrd-2.4.18-14.img

where (hd0,1)/boot/grub contains all the grub files, and the partition containing the Linux filesystem to be run has the label /.

dgonzalezh 05-18-2012 03:07 PM

Quote:

Originally Posted by RockDoctor (Post 4682134)
I don't know if this will be of any help, but long ago, I downloaded to my collection of helpful docs, a howto that explains how to restore grub-legacy. Unfortunately, I didn't document the source, so I don't know to whom the credit should go, but it's saved me many, many times. Anyway, heres an example taken from that howto:
Code:

title Red Hat Linux (2.4.18-14)
        root (hd0,1)
        kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ hdc=ide-scsi
        initrd /boot/initrd-2.4.18-14.img

where (hd0,1)/boot/grub contains all the grub files, and the partition containing the Linux filesystem to be run has the label /.

Thanks Doctor,

As soon as my brother gets to the office and can turn on the server (remote location) I'll try that. In the meantime I'd like to know what's the file that grub looks for when it goes into stage2 grub.conf or menu.lst?, I have them both, menu.lst being a symlink to grub.conf.

Also as I have my root filesystem on LVM I have this cryptic line.

Code:

title CentOS (3.2.6-0.choon.centos6.x86_64)
        root    (hd0,0)
        kernel  /xen.gz loglvl=all guest_loglvl=all dom0_max_vcpus=1 dom0_vcpus_pin conswitch=g dom0_mem=384M console=vga
        module  /vmlinuz-3.2.6-0.choon.centos6.x86_64 ro root=/dev/mapper/vgMaster-root nomodeset rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vgMaster/swap rd_LVM_LV=vgMaster/root KEYBOARDTYPE=pc KEYTABLE=es rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto rd_NO_DM earlyprintk=xen console=hvc0
        module  /initramfs-3.2.6-0.choon.centos6.x86_64.img

That is workin on the other server which is almost the same as this one, but I get stuck at the grub prompt.

Code:

Probing devices to guess BIOS drives. This may take a long time.


    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
  lists possible command completions.  Anywhere else TAB lists the possible
  completions of a device/filename.]

grub>

I'll try your suggestion and tell you how this goes.

Thanks for taking the tme to answer.

RockDoctor 05-18-2012 03:46 PM

I think menu.lst is the standard name for the file, although Red Hat and its derivatives use grub.conf and simlink it with menu.lst.

I stay away as far away from lvm as I can, which is a good thing given that I have absolutely no knowledge regarding how to set it up or what a valid gurb.conf/menu.lst configuration should look like. Someone more knowledgeable than I will have to help you decipher that one.

Knightron 05-18-2012 08:28 PM

I've no knowledge on LVM or Grub.conf. I've Arch and Opensuse on my system plus a boot partition for chainloading that i set up, and all three run Grub Legacy, and none have a grub.conf to my knowledge.
Here's my tip:
In your first post, you stated it was a "/boot partition"
In your menu.list, are you setting root to the right place?
Quote:

title CentOS (3.2.6-0.choon.centos6.x86_64)
root (hd0,0)
That's pointing to /dev/sda1
I don't know the details behind your partitions, but that line needs to point to your root partition.
This could likely be your problem. Sometimes the simple things get overlooked.

dgonzalezh 05-18-2012 08:46 PM

Thank you very much for your advise I'll try it tomorrow because server is remote and I started it manually and it's running so I don't wanna screw it unless there's someone there to type in commands for me.

Thank you very very much.

syg00 05-18-2012 09:52 PM

Quote:

Originally Posted by Knightron (Post 4682295)
In your menu.list, are you setting root to the right place?

That's pointing to /dev/sda1
I don't know the details behind your partitions, but that line needs to point to your root partition.

Nope.
The root (hd?,?) is for the grub root directory.
The root=???? keyword on the kernel command is what points the kernel to your Linux root directory.

Totally separate concepts.

@dgonzalezh are you running under Xen or not ?. If you booted as per post #1, it doesn't look like Xen.
Perhaps go here, and let us see the RESULTS.txt so we can see what installed where.

dgonzalezh 05-18-2012 10:19 PM

1 Attachment(s)
Quote:

Originally Posted by syg00 (Post 4682330)
Nope.
The root (hd?,?) is for the grub root directory.
The root=???? keyword on the kernel command is what points the kernel to your Linux root directory.

Totally separate concepts.

That's clear for me, fortunately I corrected some problems now I'll show you what I have did and the system boots into grub prompt and I can start he OS from there issuing

Code:

kernel /xen.gz
module /vmlinuz ro root=/dev/mapper/vgMaster-lvRoot
module /initrd.img

It starts fine but if it happens to reboot as it's been all day because of power failures there it stays at grub>_ prompt.

I did this, to try to recover

Code:

grub> find /grub/stage1
find /grub/stage1
 (hd1,0)
grub> root (hd1,0)
root (hd1,0)
 Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1)
setup (hd1)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd1)"...  27 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd1) (hd1)1+27 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.

And the rest you can see at results.txt.

I even tried find /grub/grub.conf and it worked, found the file at (hd1,0)

Quote:

@dgonzalezh are you running under Xen or not?. If you booted as per post #1, it doesn't look like Xen.
Yes Sr. I'm running XEN 4.1.2 and this is a heavy duty server like 24 DomUs here, so a mission critical server.

Quote:

Perhaps go here, and let us see the RESULTS.txt so we can see what installed where.
Roger, on my way...

After looking at it I see that Grub is installed on both /sda and sdb and my grub stuff is located at sbd.

Here's some info that the script didn't get

OS: CentOS 6.2 x86_64
XEN: 4.1.3-rc2-pre

I see that everytjing looks like it's fine now, but as I said the server is miles away from me and as it's late now no one there to issue commands if I screw things up, but I guesss I'm a hair away from getting the server back to normal operation.

Thanks for your replies, that's why I use GNU/Linux, you're the best people.

syg00 05-18-2012 10:55 PM

Looks like the last bit you need is to do the setup to hd0, not hd1. The BIOS will (in all likelihood) be set to boot that.

dgonzalezh 05-18-2012 11:05 PM

Quote:

Originally Posted by syg00 (Post 4682350)
Looks like the last bit you need is to do the setup to hd0, not hd1. The BIOS will (in all likelihood) be set to boot that.

Well, I tried that and no luck, I still don't reboot, but according to my research sda/hd0 is not the place where grub shuld be installed, I might be wrong.

Code:

[root@xen ~]# cat /boot/grub/device.map
# this device map was generated by anaconda
(hd0)    /dev/sdb
(hd1)    /dev/sda
[root@xen ~]# grub
Probing devices to guess BIOS drives. This may take a long time.


    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
  lists possible command completions.  Anywhere else TAB lists the possible
  completions of a device/filename.]
grub> setup (hd0)
setup (hd0)

Error 1: Invalid device requested
grub> root (hd0,0)
root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
setup (hd0)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... no

Error 15t: File not found
grub> map
map

Error 11t: Unrecognized device string
grub> root (hd1,0)
root (hd1,0)
 Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1)
setup (hd1)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd1)"...  27 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd1) (hd1)1+27 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.
grub> quit
quit

I don't want to reboot until I'm sure it won't be stuck at grub prompt.

Again apreciate your insight and help.

syg00 05-18-2012 11:19 PM

Quote:

grub> root (hd1,0)
root (hd1,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1)
The "root (hd1,0)" has to stay - it identifies where the grub code is located. But the "setup (hd1)" needs to change to "setup (hd0)". This is what writes the MBR code, and it points back to whatever the "root ..." identified.

dgonzalezh 05-18-2012 11:32 PM

Quote:

Originally Posted by syg00 (Post 4682363)
The "root (hd1,0)" has to stay - it identifies where the grub code is located. But the "setup (hd1)" needs to change to "setup (hd0)". This is what writes the MBR code, and it points back to whatever the "root ..." identified.

Ok, you're absolutely right, I did as you said and here's what I got.

Code:

grub> root (hd1,0)
root (hd1,0)
 Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1)
setup (hd1)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd1)"...  27 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd1) (hd1)1+27 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.

Would it be safe to reboot now?.

Thanks.


All times are GMT -5. The time now is 08:23 PM.