on it road .com

使用 xfs_repair 修复 XFS 文件系统

xfs_repair 实用程序可用于修复损坏或者损坏的 XFS 文件系统。
xfs_repair 使用的基本语法如下:

# xfs_repair /mount/point

与 fsck 实用程序类似,xfs_repair 实用程序在一系列阶段中修复未挂载的 xfs 文件系统。
XFS 修复的示例输出如下所示:

# xfs_repair /dev/mapper/vg_test-lv_test 
Phase 1 - find and verify superblock...
        - reporting progress in intervals of 15 minutes
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
        - 12:57:37: scanning filesystem freespace - 291 of 291 allocation groups done
        - found root inode chunk
Phase 3 - for each AG...
        - scan and clear agi unlinked lists...
        - 12:57:37: scanning agi unlinked lists - 291 of 291 allocation groups done
        - process known inodes and perform inode discovery...
        ...
        ...
Metadata corruption detected at xfs_inode block 0x60/0x2000
Metadata corruption detected at xfs_inode block 0x60/0x2000
Metadata corruption detected at xfs_inode block 0x60/0x2000
Metadata corruption detected at xfs_inode block 0x60/0x2000
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - 12:57:37: setting up duplicate extent list - 291 of 291 allocation groups done
        - check for inodes claiming duplicate blocks...
Phase 5 - rebuild AG headers and trees...
        - 12:57:37: rebuild AG headers and trees - 291 of 291 allocation groups done
        - reset superblock...
Phase 6 - check inode connectivity...
        - resetting contents of realtime bitmap and summary inodes
        - traversing filesystem ...
        - traversal finished ...
        - moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
        - 12:57:37: verify and correct link counts - 291 of 291 allocation groups done
done

如果我们只想检查文件系统问题,但不想修复任何问题,请运行 xfs_check 命令而不是 xfs_repair 命令。

# xfs_check /dev/mapper/vg_test-lv_test 
Metadata corruption detected at xfs_inode block 0x40/0x8000
Metadata corruption detected at xfs_inode block 0x40/0x8000
Metadata corruption detected at xfs_inode block 0x40/0x8000
Metadata corruption detected at xfs_inode block 0x40/0x8000
bad magic number 0xfe3d for inode 100
bad magic number 0xa756 for inode 101
bad magic number 0xd375 for inode 102
bad magic number 0x88f5 for inode 103
bad magic number 0xc7cd for inode 104
         69 file1

我们也可以使用“xfs_repair -n”命令对 xfs_repair 进行试运行。
某些发行版不包括 xfs_check 命令。
在这种情况下,我们可以使用此选项,因为它们的工作方式相同。

# xfs_repair -n /dev/mapper/vg_test-lv_test 
.....
Phase 7 - verify link counts...
        - 13:02:55: verify and correct link counts - 291 of 291 allocation groups done
No modify flag set, skipping filesystem flush and exiting.
在 XFS 文件系统上运行修复

XFS 文件系统是一个高性能的日志文件系统。
XFS 支持的最大文件系统大小为 500 TB,最大文件大小为 16 TB。
我们可以在常规磁盘分区和逻辑卷上创建 XFS 文件系统。
它在重负载和大文件扩展下表现非常出色,但因此,它也容易受到损坏,正是考虑到这一点,我们现在考虑一组工具,使我们能够对服务器进行故障排除和恢复文件系统。

其他 XFS 实用程序可用于执行文件系统维护。
这些实用程序包括:

  • xfs_fsr :XFS 是一个基于盘区的文件系统。 xfs_fsr 实用程序重新组织并改进了文件范围的布局,从而提高了整体性能。在挂载的 XFS 文件系统或者文件系统中的单个文件上运行此命令。
  • xfs_repair :修复损坏或者损坏的 XFS 文件系统。在运行此命令之前卸载文件系统。如果无法修复文件系统,请使用 xfsrestore 从备份中还原文件。
  • xfs_db :调试 XFS 文件系统。此实用程序提供了一个命令集,允许我们对文件系统执行扫描以及导航和显示其数据结构。
日期:2020-09-17 00:14:18 来源:oir作者:oir