GRUB
Troubleshooting – 5
-->
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.
-->
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.
--> 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
--> 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
--> 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