Fixing a Corrupted /boot Partition on Oracle and Red Hat Linux 7/8/9

In this tutorial, we will learn how to fix a corrupted /boot partition on the Linux OS.


Note:

-It is recommended to try out these procedures on a Test System before attempting on the Production System.

-Always backup the system before making any changes.

-Run all commands as root or sudo.


1. Determine what partition is /boot mounted on (ie. /dev/sda1) and what type of filesystem (ie. xfs) is used.


Example:

# mount|grep "/boot"
   /dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)

2. Backup /boot directory.


Example:

   # cp -rp /boot /boot.bak1

3. Boot into emergency mode.


a. Reboot.


b. Press “e” when boot-loader appears. This will allow you to edit the current menu entry.


c. Navigate to the line that starts with Linux and append systemd.unit=emergency.target to the end of the line.

Example:

       linux16 /vmlinuz-4.1.12-112.16.4.el7uek.x86_64 root=/dev/mapper/rootvg-rootlv ro ipv6.disable=1 net.ifnames=0 selinux=0 audit=1 norhgb crashkernel=auto rd.lvm.lv=rootvg/rootlv rd.lvm.lv=rootvg/swaplv rhgb quiet numa=off transparent_hugepage=never systemd.unit=emergency.target

d. Press CTRL + x to boot using the modified configuration.

Note: This edit is temporary and will revert back to the original configuration upon the next reboot.


e. Enter root password to log into emergency mode.


4. Repairing the /boot partition.


From step 1, /boot was found to be mounted on /dev/sda1 and have a filesystem type of xfs.


a. Repairing xfs boot partition.


First do a test:

	# xfs_repair -n /dev/sda1

If any corruptions are found, fix it:

	# xfs_repair /dev/sda1

	# reboot

If you have ext (ie. ext2, ext3, ext4) filesystem instead of xfs, then use fsck, as shown below, instead of xfs_repair.


b. Repairing ext2/3/4 filesystem.

First do a test:

	# fsck -n /dev/sda1

If any corruptions are found, fix it:

	# fsck -y /dev/sda1

	# reboot