Linux Admin Reference – RedHat Linux Grub Loader

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 #1 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

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,1)
# kernel /boot/vmlinuz-version ro root=/dev/hda2
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=0

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.

 

2. 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

 

3.  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

 

 

4. How to  Disable  fsck  of    file systems from the grub menu?

At the grub prompt edit the boot parameters.
This is usually done by pressing e at the menu.

At the end of the ‘kernel’ line add ‘fastboot‘ without the quotation marks. This is what skips the filesystem check.

Exit the grub mode and  boot the system.

 

5. How to Configure one time use of Specific Kernel Entry to boot,  in Grub Menu ?  

 

Using grub Command:

# grub
grub> savedefault –stage2=/boot/grub/stage2 –default=2 –once

Or invoking grup from a shell script:

# echo “savedefault –stage2=/boot/grub/stage2 –default=1 –once” | grub

Please notice that savedefault does not change the grub.conf, it just change the binary code within stage2 file /boot/grub/stage2.

 

6. Grub not starting the count down of Timeout value during booting, and we have to hit enter manually to boot from default kernel.

Either Hardware Clock of the Server not working, or had not working. Fixing the Hardware clock should resolve the issue.

 

7. How to find nextboot order when using grub “savedefault” option?

use the below command to know the next boot order set with save default option

# xxd /boot/grub/stage2 |awk ‘ /0000200/ {print $8}’

 

8. How to boot into single user mode using the GRUB bootloader?

Single user mode can be accessed by appending an “S”, “s”, or “single” to the kernel command line in GRUB. To do this, restart the system and when the GRUB splash screen presents itself:

Select/highlight the desired kernel using the up/down arrow keys.

Press the letter a to modify the kernel line.

On the new screen, press the spacebar to add a space, then type the letter s and press Enter.

This will boot the system into single user mode, i.e. the boot process will stop immediately after execution of rc.sysinit and present a root BASH shell.

Note:

Adding “S”, “s”, or “single” to the kernel command-line tells the kernel to to have init drop to a root shell after rc.sysinit finishes. This allows one to get into the system without a password and bypass any problems with services.

Adding “1” to the kernel command-line seems to do basically the same as above, but in reality init also kicks off rc for runlevel 1 before dropping to a root shell. This means that in runlevel 1, there could possibly be some services running (if they were configured in /etc/rc1.d).

 

9. How Troubleshoot the if the server hangs at GRUB prompt during boot?

Sometime, when SAN disks connected to the system were detected before the local hard disk. And the the local hard disk will be recognized as /dev/sdg instead of /dev/sda so the GRUB pointed to wrong device to boot from.To Diagnosis and troubles we can use the below guidelines

1. Boot  into Rescue mode, using CD#1 or Network Boot

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.

2. chroot the / filesystem

Before we troubleshoot 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

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,1)
# kernel /boot/vmlinuz-version ro root=/dev/hda2
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=0

3. Execute grub-install command for the / filesystem.

In this case it is in the MBR of the sda device, To restore the bootloader, execute:

# grub-install /dev/sda

4. Reboot the system

5. When you see GRUB splash screen, hit space key

6. Highlight the server title line, for example “Red Hat Enterprise Linux Server-base (2.6.18-53.el5)” , then type c key to drop into the command line.

7. At the grub prompt, use find command to find out which device has a kernel image (vmlinuz) and driver image (initrd).

If your system has a separate /boot partition, type

grub> find /initrd-2.6.18-53.el5.img
(hd0,0)

If your system does NOT have a separate /boot partition, type

grub> find /boot/initrd-2.6.18-53.el5.img
(hd0,0)

8. Using the device name found in the step 7, set up root as “hd0,0”.

grub> root (hd0,0)

9. Set up kernel image AND the location of / filesystem. This should look like the kernel line in /boot/grub/grub.conf.

If your system has a separate /boot partition, type

grub> kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/1 rhgb quiet

If your system does NOT have a separate /boot partition, type

grub> kernel /boot/vmlinuz-2.6.18-53.el5 ro root=LABEL=/1 rhgb quiet

10. Set up driver image (initrd).

If your system has a separate /boot partition, type

grub> initrd /initrd-2.6.18-53.el5.img

If your system does NOT have a separate /boot partition, type

grub> initrd /boot/initrd-2.6.18-53.el5.img

11. Type boot command to boot with the setting made above steps.

grub> boot

 

10. How do I change the default kernel in GRUB that is loaded at startup?

 

Use the command grubby –bootloader-probe to find out which bootloader you have installed. Then, assuming it is GRUB, edit the file /etc/grub.conf as described below. First, an example GRUB configuration file:

default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz

title Red Hat Enterprise Linux ES (kernel number zero)
root (hd0,0)
kernel /vmlinuz-zero ro root=/dev/hard_drive
initrd /initrd-zero.img

title Red Hat Enterprise Linux ES (kernel number one)
root (hd0,0)
kernel /vmlinuz-one ro root=/dev/hard_drive
initrd /initrd-one.img

title Red Hat Enterprise Linux ES (kernel number two)
root (hd0,0)
kernel /vmlinuz-two ro root=/dev/hard_drive
initrd /initrd-two.img

In this example file, notice the line at the top that reads default=0. The number 0 (zero) indicates which stanza to select by default. A stanza is the indented portion after the line starting with title. GRUB will then use this default stanza to boot, after a number of seconds has passed (specified in the line timeout=10). The 0 (zero) in this case is referring to the first stanza that starts with “title Red Hat Enterprise Linux ES (kernel number zero)”. It includes all of the indented lines up to but not including the next “title” line.

For example, if you instead wanted the second stanza, “title Red Hat Enterprise Linux ES (kernel number one)”, to be the default, then you would change the default line to:

default=1

Once you have made this change, save the grub.conf file. You do not need to reload GRUB for the changes to take effect. The next time you boot, your changes will take effect, but once the file is saved, the changes are effective.

 

 

11. How to install GRUB on a disk image file?

Image files are representations of block devices. Each image can be used as a hard disk for virtualized guests under Xen or KVM. During booting, if GRUB bootloader cannot recognize a boot partition installed a virtual machine for any reason, need to re-install GRUB on that image file. It will be especially useful when trying to migrate a physical machine to a virtual machine using a disk image file from scratch.

Assumptions: There is a disk image file, so-called virtual-disk.img, for virtual machines. The image has beed made well including a proper kernel version and other system packages. To build a disk image file, refer the How can I create sparse files under Red Hat Enterprise Linux?

Before installing GRUB, get partition information from the image.

# losetup /dev/loop1 /var/lib/libvirt/images/virtual-disk.img
# fdisk -ul /dev/loop1
Disk /dev/loop1: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x722fd0f4

Device Boot Start End Blocks Id System
/dev/loop1p1 63 1060289 530113+ 82 Linux swap
/dev/loop1p2 1060290 16771859 7855785 83 Linux
# losetup -d /dev/loop1

In this example, virtual-disk.img is consists of two partitions and is 8GiB in total size. Now install GRUB to the image file:

# grub –device-map=/dev/null

This will open up a GRUB prompt. Enter the following:

grub> device (hd0) /var/lib/libvirt/images/virtual-disk.img
grub> root (hd0,1)
grub> setup (hd0)
grub> quit

Note: do not use the loopback device to install GRUB bootloader because GRUB has a bug when given a loopback device.

 12. How do I configure GRUB to see all of my physical memory?

You can specify the amount of memory on your system if your computer is not recognizing all of it. For example if your system says you only have 128 MB of RAM and you know for sure you have 256 MB, then you can specify that in your grub.conf file, located at /boot/grub/grub.conf.

This is what a normal grub.conf file looks like:

# cat /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/hda2
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Enterprise Linux AS (2.4.21-15.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-15.EL ro root=LABEL=/
initrd /initrd-2.4.21-15.EL.img
title Red Hat Enterprise Linux AS (2.4.21-9.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-9.EL ro root=LABEL=/
initrd /initrd-2.4.21-9.EL.img

What you want to do is add the following syntax mem=<###>M to the kernel line of your grub.conf file. So for instance if you were specifying your system had 256 MB in the grub.conf file, it would look something like this:

# cat /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/hda2
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Enterprise Linux AS (2.4.21-15.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-15.EL ro root=LABEL=/ mem=256M
initrd /initrd-2.4.21-15.EL.img
title Red Hat Enterprise Linux AS (2.4.21-9.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-9.EL ro root=LABEL=/ mem=256M
initrd /initrd-2.4.21-9.EL.img

 

 13. Grub Boot Fails with Following Error : Error 15: File not found  & Error 17: Cannot mount selected partition

1) At the grub screen, press ‘c’ to enter command line mode

2) Tell grub to search for the grub boot files.

grub> find /grub/stage1

if no disks are returned in step 2, it indicates that grub is unable to mount and find the files. rescue mode will be required to repair the file-system and grub boot files.

Grub will attempt to access the disk listed in the ‘root’ parameter for the bootloader files (/boot/grub).

If the ‘root’ device is incorrect, or the device is inaccessible, an error will be displayed.

3) Note the disk that is returned. Usually, this will be (hd0,0)

4) Press ‘esc’ to return to the menu

5) Press ‘e’ to enter the configuration menu

6) Press ‘e’ on the root parameter, and adjust the line to match the disk that was returned earlier. Press return to save the changes.

root (hd0,0)

7) Press ‘b’ to boot with the new configuration

8) Once the machine is booted, modify the /boot/grub/grub.conf file to make the change permanent

root(hd0,0)

 

14. How do we activate power management or Advanced Power Management (APM) , from GRUB?

APM packages are available only for 32 bit machine. The apmd package is very old and it has replaced by “acpi”(Advanced Configuration and Power Interface) package. The acpid daemon works to control the power of the devices.

Activating APM:  Advanced Power Management features (APM) can be activated on your system by starting the APM daemon (apmd). To start this immediately, use the service command:

# service apmd start

To ensure that this daemon is enabled across reboots, use the chkconfig command:

# chkconfig apmd on

Note: In order to execute these commands, user has to be the root user.

Confirm that APM was activated :

#dmidecode | grep -i apm

#service apmd status
#/etc/init.d/apmd status
#ps aux | grep apmd
#pstree -paul| grep apmd

Disabling  APM:

On 32bit machine you can pass the apm parameter and its value to the kernel to disable it during booting. Just the add the “apm=off” at the end of the line contains “kernel” in the grub.conf file.

Sample grub.conf entries it will look like

default=1
timeout=7
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux AS (2.4.21-20.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-20.EL ro root=LABEL=/ apm=off
initrd /initrd-2.4.21-20.EL.img
title Red Hat Enterprise Linux AS (2.4.21-20.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.4.21-20.ELsmp ro root=LABEL=/ apm=off
initrd /initrd-2.4.21-20.ELsmp.img

And on that same machine you also need to disable the apmd daemon at the chkconfig service like :

#chkconfig apmd off
#service apmd stop

 

 15. System kernel panics on boot with “mount: could not find filesystem ‘/dev/root'”.

System kernel panics on boot with the following information after loading GRUB and starting the boot process:

Unable to access resume device (/dev/rootvg/swap)
mount: could not find filesystem ‘/dev/root’
setuproot: moving /dev failed: no such file or directory
setuproot: error mounting /proc: no such file or directory
setuproot: error mounting /sys: no such file or directory
switchroot: mount failed: no such file or directory
kernel panic – no syncing: attempted to kill init!

This issue can occur when a yum install of a new kernel is interrupted, the initrd won’t be properly rebuilt for the new kernel resulting in many problems at boot.

Rollback to the previously installed kernel by booting into the older kernel via the GRUB bootloader. Press any key when “Starting Red Hat Enterprise Linux in 5 seconds…” appears. Then once inside of GRUB use the arrow keys to navigate down to the second line and press the ‘b’ key to boot into the selected kernel.

To make the second kernel the default edit /boot/grub/grub.conf and modify the line default= to read:

default=1

If the above works try re-installing the kernel with yum by first removing the new kernel and then installing it. For example to reinstall the 2.6.18-308.8.1 kernel:

# yum -y remove kernel-2.6.18-308.8.1.el5.x86_64
# yum -y install kernel-2.6.18-308.8.1.el5.x86_64

16. How do I change a forgotten root password?

we can change  root password from either single user mode or rescue mode. The method for booting into single user mode depends on your bootloader:

GRUB – No password protection

Booting into single user mode using GRUB is accomplished by editing the kernel line of the boot configuration. This assumes that either the GRUB boot menu is not password protected or that you have access to the password if it is.

When the system boots up, you will see the GRUB countdown, which is set to 5 seconds by default . Press “Esc” to intercept this countdown and go enter a GRUB menu. Then follow these steps:

Press ‘e’ to start editing.
Scroll down to the “kernel…” line. This line tells GRUB which kernel to boot.
Press ‘e’ again to edit this line.
Move to the end of the line. Add the number “1” to the end.
Once you have finished that change, press Enter to accept the edit.
Press ‘b’ to boot using that kernel and boot into runlevel 1 (single user mode).
Change the root password when the “#” prompt appears by using the “passwd” command.

Note: The switch to runlevel 1 is not persistent. At next boot, the system will start in default runlevel as specified in the /etc/inittab file.

GRUB – Password protection

If the GRUB boot menu is password protected and you do not have access to the password, you will need to use a rescue disk to boot the system.

Follow the instructions given by the rescue disk boot process:

Boot the system from boot disc 1. Once the system has successfully booted from the ISO image and the Red Hat Enterprise Linux boot screen appears, type “linux rescue” without the quotes at the boot prompt and press the enter key.
[F1-Main] [F2-Options] [F3-General] [F4-Kernel] [F5-Rescue]

boot: linux rescue
When prompted for language and keyboard, provide the pertinent information for the system. When prompted to enable the network devices on the system, select “No”.
Select “Continue” when prompted to allow the rescue environment to mount the Red Hat Enterprise Linux installation under the /mnt/sysimage directory.

Run the command “chroot /mnt/sysimage” to change root to your system image.
Use the command “passwd” to change the root password of the system.

17. How do I reinstall a corrupted boot partition in Red Hat Enterprise Linux?

 In a system where the “/boot” partition is a separate partition, when /boot is corrupted or be formatted mistakenly, you can not boot the system but do not want to reinstall the whole system.

Reinstall /boot partition manually with the following steps:

1. Boot the system into rescue mode:

Insert the Red Hat Enterprise Linux CD #1 and boot your system. At boot prompt, type “linux rescue”. This will start the rescue mode program.

You will be prompted for your keyboard and language requirements. Enter these values as you would during the installation of Red Hat Enterprise Linux.

Next, a screen will appear telling you that the program will now attempt to find a Red Hat Enterprise Linux installation to rescue. Select “Continue” on this screen.

At the “sh-3.1” prompt, chroot to /mnt/sysimage:

# chroot /mnt/sysimage

2. Make sure the boot partition is labeled as described in /etc/fstab. (Assuming the boot partition is /dev/sda1):

# e2label /dev/sda1 /boot

3. Make sure the boot partition is mounted:

# mount /dev/sda1 /boot

4. Mount the CD to install the following rpms:

# mkdir /mnt/iso
# mount -o loop,ro /dev/hdc /mnt/iso
# cd /mnt/iso/Server
# rpm -Uvh –replacefiles –replacepkgs grub-0.97-13.i386.rpm
# rpm -Uvh –replacefiles –replacepkgs redhat-logos-4.9.16-1.noarch.rpm
# rpm -ivh –replacefiles –replacepkgs kernel-2.6.18-8.el5.i686.rpm

5. Install the GRUB:

# grub-install /dev/sda

6. If /boot/grub/grub.conf is lost, you need to create it manually. The following is a sample of grub.conf, please make sure the the file “vmlinuz-2.6.18-8.el5” and “initrd-2.6.18-8.el5.img” exist under the directory of /boot (which should be installed after step 4).

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu

title Red Hat Enterprise Linux (2.6.18-8.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/
initrd /initrd-2.6.18-8.el5.img

7. Make a soft link to grub.conf:

# cd /boot/grub
# ln -s grub.conf menu.lst

Then you can reboot your system.

 

  18.  How to disable hyperthreading if GRUB is the boot loader?

During the boot sequence you can add an option to the kernel line.

In the GRUB menu, select the kernel to boot into.

Type ‘e’ to modify the kernel arguments before booting.

Add a space then type ‘noht’ at the end of the line.

Hit return to boot with this options.

Type ‘b’ to boot to this kernel.

Permanently
Edit the /etc/grub.conf file.

Find the kernel line that you want to modify.

Add noht to the kernel line. For example:

title Red Hat Enterprise Linux Server (2.6.18-8.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-8.el5 ro root=/dev/vg0/lv0 noht
initrd /initrd-2.6.18-8.el5.img

19. How do I turn SELinux off during GRUB booting?

 

During the boot sequence you can add an option to the kernel line.

In the GRUB menu, select the kernel to boot into.

Type ‘e’ to modify the kernel arguments before booting.

Add a space then type ‘noht’ at the end of the line.

Hit return to boot with this options.

Type ‘b’ to boot to this kernel.

Permanently
Edit the /etc/grub.conf file.

Find the kernel line that you want to modify.

Add noht to the kernel line. For example:

title Red Hat Enterprise Linux Server (2.6.18-8.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-8.el5 ro root=/dev/vg0/lv0 rhgb quiet selinux=0
initrd /initrd-2.6.18-8.el5.img

 

 

20. How to display the booting log on the display always? 

 

 if the kernel entry has “rhgb” and “quiet” at the end of the line, you wont see the boot log.  To enable boot log, just modify the entries as below

Before:

title Red Hat Enterprise Linux AS (2.6.9-89.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-89.ELsmp ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-89.ELsmp.img

After:

title Red Hat Enterprise Linux AS (2.6.9-89.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-89.ELsmp ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.9-89.ELsmp.img

 

 

Ramdev

Ramdev

I have started unixadminschool.com ( aka gurkulindia.com) in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. And the result is today's' unixadminschool.com. You can connect me at - https://www.linkedin.com/in/unixadminschool/

9 Responses

  1. Diptanu Paul says:

    Excellent Articles and demonstation…
    Keep up the good work….

    • Kevin Lee says:

      Hello Ramdev,

      Your blog is such a complete read. I like your approach with Linux Admin Reference – RedHat Linux Grub Loader. Clearly, you wrote it to make learning a cake walk for me.

      I have a rather old, slow laptop that I would like to put Linux on. Out of the operating systems that I’ve used, my favorite is Ubuntu. Now that I’m looking for one to put on the laptop, I’m not sure whether I should get Ubuntu, Kubuntu, or Xubuntu. I will mainly be using the laptop for word processing and some web surfing.

      But nice Article Mate! Great Information! Keep up the good work!

      Obrigado,
      Kevin

  2. satyajit das says:

    Could you please upload an article on pxeboot linux ?????

  3. raju says:

    Excellent Article, Really helped me a lot with this articles…

  4. lokesh says:

    really superb….. this post helps lot in real time…..

  5. Nitin says:

    Thanks Ramdev. There were lot of situations you mentioned and very nicely explained.
    No.19 has a copy and paste mistake.
    Thanks a lot for the wonderful blog.
    Please keep up the good work.

  6. sukhpreet says:

    reallyn ice article.. got to know such wonderful scenarios…

  7. alphonsa says:

    Hi sir,

    Im many interview asked to tell us about any big real time linux related issues. Please let us know how to answer this question.
    what senario we can g ive here.

  1. September 17, 2015

    […] Read – Linux Admin Reference – RedHat Linux Grub Loader […]

What is in your mind, about this post ? Leave a Reply

Close
  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us