How to perform filesystem check (fsck) in the rescue mode?
This document (000020980) is provided subject to the disclaimer at the end of this document.
Environment
- SUSE Linux Enterprise Server 12, 15
- XFS and EXT filesystem
- Rescue Environment
Situation
- The system is failing to boot due to filesystem corruption
- System requires OS filesystems to be repaired i.e., root filesystem or /var
- How to repair /var or /(root) filesystem which are formatted with either EXT or XFS
Resolution
- Boot the system into rescue mode by using the binary DVD or boot ISO. For best results use media that matches the version and service pack of the system.
- In the rescue mode, logical volumes are automatically activated, and same can be checked with:
# lvs
- If not, the following command can be used to manually activate the logical volumes.
# vgchange -ay
- Following commands can be used to perform a dry-run(read-only mode) of the fsck, to approximately determine how much corruption is observed. This will not make any changes to the filesystem. These steps are recommended before going further for the actual filesystem check.
# e2fsck -n /dev/mapper/<vgname>-<lvname> OR # e2fsck -n /dev/<sd device>
# xfs_repair -n /dev/mapper/<vgname>-<lvname> OR # xfs_repair -n /dev/<sd device>
- If the actual filesystem check is required, following commands can be used
# e2fsck -fyv /dev/mapper/<vgname>-<lvname> OR # e2fsck -fyv /dev/<sd device>
# xfs_repair /dev/mapper/<vgname>-<lvname> OR # xfs_repair /dev/<sd device>
- Note: One may need to replay/recreate the log if xfs_repair command fails. This can be achieved with xfs_repair -L command. However, this option should be treated as the last resort.
- Exit the rescue mode and boot the system normally.
Cause
Filesystem corruption can occur due to several reasons.
Additional Information
- man e2fsck
- man xfs_repair
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000020980
- Creation Date: 20-Feb-2023
- Modified Date:22-Feb-2023
-
- SUSE Linux Enterprise Server
- SUSE Linux Enterprise Server for SAP Applications
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com