Friday, February 13, 2015

LINUX STUCK AT GRUB MENU ON BOOT

So: After booting, you get the grub screen as below

GNU GRUB version 0.95 (639K lower / 2590524K 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>


now this basically means there is an issue with your grub and after the system goes through BIOS, its not able to load your grub menu. To try and say that one problem causes this issue is a lie, there are a number of reasons that this can happen. Bellow i take through the steps, trying to explain what you can check and hopefully your problem is among the list, if not - when you solve your issue, please get back and post a comment.

I want to believe you have your bootable DVD with you here, note, i got this error on my test virtual machine, its a centos 6 final release.

boot from DVD and follow the steps

- rescue installed system:

- English (choose your preferred)

- US (choose your preferred)

- Local CD/DVD

- No - to start network

- Gives you a prompt that tells you where the Linux installation will be mounted, please note where it says, ideally should be under /mnt/sysimage - click continue

- Rescue prompt, tells you where your image is mounted, please take note: should say - under /mnt/sysimage - click OK

- tells you the image has been mounted, click ok

- select "shell Start shell"

- now should be at bash prompt: here type

#chroot /mnt/sysimage (note here, the folder should be the one that you got told in the above steps)

- the prompt will change to, here type the following
#cd /boot/grub

- then type the following

#ls -l

- here please note if you have a file "grub.conf". then you can breath. but lets continue, try to fumble about

once in the folder, let me state some facts, please note, i as i was checking around, this blogs equally helped me a lot, check them out for more info and extensive details

http://www.thegeekstuff.com/2011/02/linux-boot-process/
http://beginlinux.com/blog/2009/09/understanding-the-grub-bootloader-course/
http://www.slashroot.in/linux-grubgrand-unified-bootloader-tutorial
http://www.dedoimedo.com/computers/grub.html

also note this doesnt describe if you have the newer grub2.2

GRUB stands for Unified Boot Loader - basically, when you power your machine it goes through some stages

1 - BIOS
2 - MBR
3 - GRUB
4 - KERNEL
5 - INIT
6 - RUNLEVEL

Of importance for us is stage 2 and 3

MBR - Master boot loader and is located in the first sector of the bootable disk, i.e. /dev/sda in our case. This has info about the grub and loads it.
GRUB - after grub is loaded, its in charge of loading the kernerl and initrd, i.e. based on how well its configured, it will load the list of installed kernel and allow you to select, upon which the appropriate kernel is loaded.

The grub config file is located in /etc/grub/grub.conf

In itself, grub works in stages

1. stage 1 is in MBR and its like a pointer to Stage2. this is because MBR is only 512 bytes and hence can not hold grub params
2. stage 1.5 - this is very small but important as it contains the file system drivers to open up the file system specific stage 2
3. stage 2 now points to the config files which will contain the whole story of how the pc is to boot, what kernels to load and the like. this config file is grub.conf. we can say here, stage 2 is responsible for loading the nice gui in which you select the OS

by default the grub package is installed on a linux system, run below to check

[root@localhost ~]# rpm -qa | grep grub
grub-0.97-13.5

Note, if it was not installed, install the rpm and then run the command below to config it

[root@localhost ~]# grub-install /dev/sda
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
# this device map was generated by anaconda
(hd0)     /dev/sda

this will install grub in the MBR of the hard disk /dev/sda

so lets say for example, grub rpm is not installed, worry not yourself. mount the cd rom and install it

#mount /dev/scd0 /mnt/
#cd /mnt/Packages
- install the rpm from here
#rpm -iv grub-******


So now we are in #cd /boot/grub

we want find that the file grub.conf was deleted or is there but has a problem, lets trouble shoot it. bellow is how the file should be

note - my system is centos 6.5
------------------------------------------------------------------------------------------------------------
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_kris-LogVol01
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.29.2.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-431.29.2.el6.x86_64 ro root=/dev/mapper/vg_kris-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_DM  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_kris/LogVol01 rd_LVM_LV=vg_kris/LogVol00 rhgb quiet
initrd /initramfs-2.6.32-431.29.2.el6.x86_64.img
title CentOS (2.6.32-358.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/vg_kris-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_DM  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_kris/LogVol01 rd_LVM_LV=vg_kris/LogVol00 rhgb quiet
initrd /initramfs-2.6.32-358.el6.x86_64.img

------------------------------------------------------------------------------------------------------------

now remember we are in rescue mode, we need to confirm that all the params are ok. note the first letters are the variable and should be as they are above, but after the variable is the params, that should be specific to you

-Check if the splashimage is in the location
#ls -l /grub/splash.xpm.gz
-the title : specific to you
-root (hd0,0)
hd: harddisk
0: means its the first hard disk and the other 0 the first partition. to confirm this, check the file /boot/grub/device.map. this will show "hd0". note this is determined on which disk /boot was installed

-kernel- to check your kernel type bellow
#uname -rms
vmlinuz-2.6.32-431.29.2.el6.x86_64

ro root=
this points to where your root partition is. to know where your root partition is, run

#df -kh
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/vg_kris-LogVol01   96G   17G   75G  18% /

check to ensure that its correct, in my case "/dev/mapper/vg_kris-LogVol01"

- next the others are specific to you, i.e. (LANG rd_NO_MD SYSFONT rd_NO_DM  KEYBOARDTYPE KEYTABLE), if you have no clue, you can have it as below, this are the bare minimum you need to boot

kernel /vmlinuz-2.6.32-431.29.2.el6.x86_64 ro root=/dev/mapper/vg_kris-LogVol01 crashkernel=auto rhgb quiet

- next line is also important: initrd /initramfs-2.6.32-431.29.2.el6.x86_64.img

it will be the same as your kernel, so for your case, please edit as appropriate. if the file was missing you can work with a bare minimum as below

#
#start here
#
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.29.2.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-431.29.2.el6.x86_64 ro root=/dev/mapper/vg_kris-LogVol01 rd_NO_LUKS rd_NO_MD crashkernel=auto rd_NO_DM  rhgb quiet
initrd /initramfs-2.6.32-431.29.2.el6.x86_64.img
title CentOS (2.6.32-358.el6.x86_64)

so incase you have gotten to this place, means you are very patient. my problem was: i had edited the grub and deleted some lines as i was playing around with it. i hence was able to recreate the lines that i had deleted.

Guys, note, this is just my experience and cant be said to be exhaustive. all the best, add your new ideas and corrections. Cheers

No comments:

Post a Comment