Reinstall Corrupted Bootloader
Overview
- The Linux rescue mode is a special boot mode for fixing critical issues, such as reinstalling a corrupted stage 1bootloader or accessing a problematic /boot file system, that have rendered the system unbootable. In this training session, you will:
- Boot the system into the rescue mode using the RHEL installation DVD with networking disabled and file systems mounted in read-write mode in the chroot environment
- Reinstall Corrupted Bootloader using grub-install
- Reinstall Corrupted Bootloader from the grub Shell
- Install Lost/Corrupted System Files
Boot RHEL into the Rescue Mode
- 1. Boot the system with the installation DVD
- 2. Choose Rescue Installed System from the boot menu and press Enter.
- 3. Select a language and keyboard on subsequent screens.
- 4. Choose Local CD/DVD and press OK.
- 5. Choose no when asked whether you want network interfaces to start in the rescue mode.
- 6. Choose Continue and press Enter.
- 7. Continue searches for a RHEL installation and, if found, mounts the / file system on /mnt/sysimage in read/write mode.
- 8. Press OK again to go to the command prompt.
- 9. Run the chroot command to make all file systems appear as if they are mounted directly under.
–# chroot /mnt/sysimage
Reinstall Corrupted Bootloader using grub-install
- 1. Boot the system into rescue mode with all file systems mounted read/write in the chroot environment.
- 2. Issue the grub-install command to reinstall the bootloader on the boot disk’s MBR:
# grub-install –root-directory=/ /dev/sda
- 3. Issue exit twice to go back, then select Reboot to restart the system.
Reinstall Corrupted Bootloader from the grub Shell
- 1. Boot the system into rescue mode with all file systems mounted read/write in the chroot environment.
- 2. Issue the grub command to invoke the grub shell:
# grub
- 3. Run the root command to set the current root device:
–grub> root (hd0,0)
- 4. Execute the setup command to install the bootloader on the /dev/sda disk:
–grub> setup (hd0)
- 5. Issue quit to exit out of the grub shell, and then exit twice to go back.
6. Select Reboot to restart the system
Install a Lost or Corrupted System File
- 1. Boot the system into rescue mode with all file systems mounted read/write in the non-chroot environment.
- 2. Copy the lost/corrupted file (in this case /bin/mount) to the /mnt/sysimage/bin directory:
# cp /bin/mount /mnt/sysimage/bin
- 3. Confirm the file copy:
# ls -l /mnt/sysimage/bin
- 4. Issue the exit command twice to go back.
- 6. Select Reboot to restart the system.