DEV Community

Cover image for How to fix RHEL file system
Syed Sadat Ali
Syed Sadat Ali

Posted on

How to fix RHEL file system

How to fix RHEL file system

To boot into rescue mode in Red Hat Enterprise Linux (RHEL) 8 and check the file system for corruption, you can follow these steps:

Boot into Rescue Mode

  1. Reboot the System:
    Restart your system.

  2. Access the Boot Menu:
    During the boot process, press a key (usually Esc, F2, F12, or a similar key, depending on your system) to access the boot menu.

  3. Select Rescue Mode:
    If using GRUB bootloader, press e to edit the boot parameters of the default kernel. Use the arrow keys to navigate to the line that starts with linux and append rd.break at the end of the line. Then press Ctrl + X to boot with these parameters.

Check and Fix File System Corruption

  1. Remount the Root File System: Once you are in the rescue shell, you will need to remount the root file system in read/write mode:
   mount -o remount,rw /sysroot
Enter fullscreen mode Exit fullscreen mode
  1. Change Root into the Sysroot: Change the root to the /sysroot directory:
   chroot /sysroot
Enter fullscreen mode Exit fullscreen mode
  1. Check and Repair the File System: Use the fsck command to check and repair the file system. Replace /dev/sdXN with your actual device identifier (e.g., /dev/sda1):
   fsck /dev/sdXN
Enter fullscreen mode Exit fullscreen mode

For example, to check the root partition, you might run:

   fsck -f /dev/sda1
Enter fullscreen mode Exit fullscreen mode
  1. Exit and Reboot: After the file system check and repair are complete, exit the chroot environment:
   exit
Enter fullscreen mode Exit fullscreen mode

Remount the file system in read-only mode:

   mount -o remount,ro /
Enter fullscreen mode Exit fullscreen mode

Reboot the system:

   reboot
Enter fullscreen mode Exit fullscreen mode

Alternative Method (Using Rescue Media)

  1. Boot from Rescue Media:
    Insert the RHEL 8 installation media and boot from it. Select the Troubleshooting option from the boot menu, then select Rescue a Red Hat Enterprise Linux system.

  2. Mount the File System:
    Follow the prompts to mount the file system. The installer will detect your RHEL installation and mount it under /mnt/sysimage.

  3. Chroot into the Mounted File System:
    Change root into the mounted file system:

   chroot /mnt/sysimage
Enter fullscreen mode Exit fullscreen mode
  1. Check and Repair the File System:
    Follow the same steps as above to run fsck and repair the file system.

  2. Exit and Reboot:
    Exit the chroot environment and reboot the system:

   exit
   reboot
Enter fullscreen mode Exit fullscreen mode

You should be able to boot into rescue mode in RHEL 8 and check and fix any file system corruption.

Top comments (0)