How to repair filesystem in rescue environment CentOS 8 & CentOS 7?

Your Linux server may not load after boot and requests fsck of the root filesystem. If this happens server filesystem goes into read-only mode.

  • When prompted for language, and keyboard, provide the pertinent information for the system.
  • Boot your server from CentOS ISO image and select rescue mode at the boot command prompt.
  • When prompted to enable the network devices on the system, select: No
  • If you are using Software RAID, first initialize the RAID array.

mdadm --assemble --scan

  • Activate the volumes in order to scan them, If using LVM.

lvm vgchange -ay
1 logical volume(s) in volume group "VolGroup00" now active

  • Run fsck on the device which has the root filesystem (ext3/ext4).

e2fsck -fvy /dev/mapper/vg device
e2fsck -fvy /dev/sd device
e2fsck -fvy /dev/md device

  • For XFS filesystem;

xfs_repair /dev/mapper/vg device
xfs_repair /dev/sd device
xfs_repair /dev/md device

  • You may have to recreate the log if xfs_repair does not run. You may implement this by running xfs_repair -L
  • Exit rescue mode and boot system normally.

Leave a Reply