Symptom
When the Linux system starts, the "Failed to mount /sysroot" error occurs, as shown in the following figure:
Reason
The log in the preceding figure contains XFS (sda2): Metadata corruption detected at xfs_agf_read_verify+... You can find that the xfs file system is corrupted and the root partition cannot be mounted, resulting in an error.
Solution
As prompted in the log, uninstall the file system and run the xfs_repair command.
The root partition cannot be mounted and thus the shell in which sulogin enters emergency mode cannot be found. Add kernel parameter rd.break (indicating dracut breaks and enters shell) to enter the shell. The operation is shown below:
In the grub boot menu and press "e" to edit the menu.
Find the linux16 /vmlinuz... line, and add kernel parameter rd.break at the end.
Press Ctrl + x to boot. In shell, run the following command.
# Use xfs_repair to fix the xfs file system. For other file systems, run the fsck.xxx command. For example, for an ext4 file system, run fsck.ext4
xfs_repair /dev/sda2 # According to the error log above, partition sda2 has the corrupted file system
# Try to manually mount /dev/sda2 and then reinstall the system mkdir -p /mnt && mount /dev/sda2
reboot