Saturday 7 June 2014

GRUB Troubleshooting 1

GRUB Troubleshooting 1

How to re-install GRUB bootloader on the Master Boot Record(MBR) in rescue mode?
The most common reason to reinstall GRUB is a disk failure and an accidental overwrite on MBR . In addition, there is also a hardware-specific reason that a SATA controller is not running in the correct mode.
To install grub-install in the MBR, boot from Red Hat Enterprise Linux installation CD in rescue mode:
boot: linux rescue
If your installation images reside on an FTP, HTTP or NFS server on your network, you need to enable it.Then, the rescue environment will ask if you wish to mount filesystems.
Select “Continue” to mount the filesystems in /mnt/sysimage with read-write mode. Now, you can access a minimal shell.
Before re-install GRUB, we change system environment so that the grub-install command thinks your root filesystem is the /mnt/sysimage directory. Below command explains the procedure
# mount -t proc none /mnt/sysimage/proc
# mount -o bind /dev /mnt/sysimage/dev
# mount -o bind /sys /mnt/sysimage/sys
# chroot /mnt/sysimage
Verify that /boot is available:
# ls -l /mnt/sysimage/boot
To make sure where the GRUB bootloader was previously installed, check the#boot=line in the configuration file:
# head /boot/grub/grub.conf
In this case it is in the MBR of the sda device.
To restore the bootloader, execute:
# grub-install /dev/sda
Type exit again to exit the rescue environment and reboot. Your bootloader should now be restored.


How to pause the boot process at GRUB menu to select a kernel ?
The Timeout value configured in the Grub configuration file allows you to chose the required kernel from Grub menu of list of available kernels. We can enable the Timeout parameter as below.
[root@~]# vim /boot/grub/grub.conf
# 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_vm27-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/vda
default=0
#timeout=5 <=== Uncomment this line, and mention no. of seconds you want to wait for user input
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.32-220.7.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.7.1.el6.x86_64 ro root=/dev/mapper/vg_vm27-lv_root rd_LVM_LV=vg_vm27/lv_root rd_LVM_LV=vg_vm27/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-220.7.1.el6.x86_64.img
title Red Hat Enterprise Linux Server (2.6.32-220.4.2.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.4.2.el6.x86_64 ro root=/dev/mapper/vg_vm27-lv_root rd_LVM_LV=vg_vm27/lv_root rd_LVM_LV=vg_vm27/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-220.4.2.el6.x86_64.img
title Red Hat Enterprise Linux Server (2.6.32-220.2.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.2.1.el6.x86_64 ro root=/dev/mapper/vg_vm27-lv_root rd_LVM_LV=vg_vm27/lv_root rd_LVM_LV=vg_vm27/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-220.2.1.el6.x86_64.img


How to give customized names for available kernels in the GRUB menu, for easy identification of purpose ?
Use “title” option to display a custom message in GRUB menu.
#vi /boot/grub/grub.conf
edit the file and use “title” option to display any informative message.
Before The Change ( without Customized Titles) :
title Select Red Hat Enterprise Linux 6 for Application A, B, C <=== Customized Title
root (hd0,0)
kernel /vmlinuz-2.6.32-220.7.1.el6.x86_64 ro root=/dev/mapper/vg_vm27-lv_root rd_LVM_LV=vg_vm27/lv_root rd_LVM_LV=vg_vm27/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-220.7.1.el6.x86_64.img
title Select Red Hat Enterprise Linux 6 For Application E, F, G <=== Customized Title
root (hd0,0)
kernel /vmlinuz-2.6.32-220.4.2.el6.x86_64 ro root=/dev/mapper/vg_vm27-lv_root rd_LVM_LV=vg_vm27/lv_root rd_LVM_LV=vg_vm27/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-220.4.2.el6.x86_64.img
title Select Red Hat Enterprise Linux 6 For Application H, I, J <=== Customized Title
root (hd0,0)
kernel /vmlinuz-2.6.32-220.2.1.el6.x86_64 ro root=/dev/mapper/vg_vm27-lv_root rd_LVM_LV=vg_vm27/lv_root rd_LVM_LV=vg_vm27/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-220.2.1.el6.x86_64.img

No comments :

Post a Comment