[转帖]xfs_respair一点理解

xfs,respair,一点,理解 · 浏览次数 : 0

小编点评

# xfs_repair 文件系统修复 **1. 主要修复** - 使用 primary superblock 的信息,对 secondary superblocks 进行修复。 - 检查是否存在 duplicate blocks 的情况,并修复它们。 - 使用 internal log 的信息,恢复 lost inode 的链接。 **2. 文件系统连接性检查** - 检查每个 inode 的连接性,并修复 broken links。 - 使用 agno 的信息,修复 damaged inodes 的链接。 **3. 修复重复块** - 使用 duplicate extent list 的信息,修复重复块的损坏。 - 使用 inodes 的信息,恢复重复块的损坏。 **4. 重建 AG headers 和树** - 使用 AGno 的信息,重建 damaged AG headers 和树。 - 使用 inodes 的信息,恢复 damaged AG 的树。 **5. 重建 AG inodes** - 使用 AGno 的信息,重建 damaged AG inodes。 - 使用 inodes 的信息,恢复 damaged AG 的 inodes。 **6. 检查 inode 连接性** - 检查每个 inode 的连接性,并修复 broken links。 - 使用 agno 的信息,修复 damaged inodes 的链接。 **7. 文件系统修复完成** - 使用 xfs_repair 的信息,检查文件系统修复是否成功。 - 如果修复失败,使用 xfs_metadump 工具保存元数据,恢复修复前的状态。

正文

xfs_respair一点理解

robot_test_boy

IP属地: 江苏
0.276
2020.08.29 20:05:38
字数 2,449
阅读 2,485
上次学习了xfs文件系统,里边大致提了下xfs_respair怎么使用的,但是xfs_respair具体干嘛的并不清楚。

xfs_repair repairs corrupt or damaged XFS filesystems (see xfs(5)). The filesystem is specified using the device argument which should be the device name of the disk partition or volume containing the filesystem. If given the name of a block device, xfs_repair will attempt to find the raw device associated with the specified block device and will use the raw device instead.

Regardless, the filesystem to be repaired must be unmounted, otherwise, the resulting filesystem may be incon‐sistent or corrupt.

xfs_repair修复损坏的XFS文件系统。指定文件系统的设备参数包含文件系统的磁盘分区或卷的设备名称。如果给定了块设备的名称,则xfs_repair将尝试查找与指定块设备关联的原始设备,并将使用原始设备代替。

xfs_respair使用前提是文件系统是卸载状态否则会造成文件系统的不一致或损坏。

Checks Performed Inconsistencies corrected include the following:
一致性检查包括如下:

  1.    Inode and inode blockmap ( addressing) checks: bad magic number in  inode, bad  magic  numbers  in  inode blockmap  blocks,  extents  out  of order, incorrect number of records in inode  blockmap blocks, blocks claimed that are  not in a legal data area of the filesystem,  blocks that are claimed by more  than  one inode.

Inode索引节点和inode索引节点块检查:索引节点的错误魔术数字,索引节点块的错误魔术数字,扩展区乱序,索引节点块中错误的记录数,文件系统中声明的不在合法数据区域块,由多个inode索引节点声明的块。

  2.    Inode  allocation  map  checks:  bad  magic number in inode map blocks,  inode state as indicated by map (free or in-use) inconsistent with state indicated by  the inode, inodes referenced  by  the  filesystem that  do  not  appear  in  the  inode  allocation map, inode allocation  map referencing blocks that do not  appear to contain inodes.

inode索引节点分配的映射检查:索引节点映射块的错误魔鬼数字,映射指示的索引节点状态和节点本身的状态不一致,文件系统的索引节点并没有出现在索引节点分配的映射中,索引节点分配的映射中未包含的索引节点。

  3.    Size checks: number of blocks  claimed by inode inconsistent with inode  size, directory size  not  block aligned,  inode  size not consistent with inode  format.

文件大小检查:声明的块大小和索引节点大小不一致,目录大小未按块对齐的,索引节点大小和索引节点格式不一致。

  4.    Directory  checks:  bad  magic  numbers in directory blocks, incorrect  number of entries in a directory block, bad  freespace information in a directory leaf  block, entry pointing to an unallocated (free)  or out  of  range  inode, overlapping  entries, missing or incorrect dot and dotdot entries, entries out of hashvalue order,  incorrect internal directory pointers,  directory type not consistent with inode  format and size.

目录检查:目录块的错误数字,目录块中的错误个数的条目,目录叶块中错误的free空间信息,指向未分配的或超出范围的inode的条目,重叠的条目,缺失或不正确的dot和dotdot条目,哈希值顺序不符的条目,错误的内部目录指针,目录类型与inode格式和大小不一致。

  5.    Pathname  checks:  files or  directories not referenced by a pathname  starting from the filesystem root,  illegal  pathname  components.

路径名检查:从文件系统根目录开始的路径名未引用的文件或目录,非法的路径名组件。

  6.    Link count checks: link counts that do not agree with the number of directory  references to the inode.

链接计数检查:链接计数与索引节点的目录引用数量不一致。

  7.    Freemap checks: blocks claimed  free by the freemap but also claimed by an  inode,  blocks  unclaimed  by any inode but  not appearing in the freemap.

Freemap检查:通过freemap声明的块但也是索引节点声明的,不是任意索引声明的块但没有出现在freemap中。

  8.    Super  Block checks: total free  block and/or free i-node count incorrect,  filesystem geometry inconsistent,  secondary and primary superblocks  contradictory.

超级块检查:总空闲块和空闲索引节点计数错误,文件系统几何图不一致,次要和主要的超级块相互矛盾。

Orphaned files and directories (allocated, in-use but unreferenced) are reconnected by placing them in the lost+found directory.The name assigned is the inode number.

通过将孤立的文件和目录(已分配,使用中但未引用)放置在lost + found目录中,以重新连接它们。分配的名称为inode编号。

Disk Errors

  XFS  has  both  primary  and  secondary superblocks.  xfs_repair uses information  in the primary superblock to automatically  find and validate the primary superblock  against the secondary  superblocks  before  proceeding.

  Should  the primary be too corrupted to be useful in locating the secondary  superblocks, the program scans the filesystem until it finds and validates some  secondary superblocks.  At that point,  it  generates  a  primary superblock.

XFS有主要和次要两个超级块。xfs_respair处理修复前,用主要超级块里的信息自动地将主要超级块和次要超级块做对比。

如果主要超级块损坏太严重而无法用于定位次要超级块,则程序将扫描文件系统,直到找到并验证一些次要超级块为止。 此时,它会生成一个主要超级块。

xfs_repair issues informative messages as it proceeds indicating what it has found that is abnormal or any corrective action that it has taken。
xfs_repair在进行时会发出提示性消息,提示发现的异常或已采取的任何纠正措施。

disconnected inode ino, moving to lost+found:An inode numbered ino was not connected to the filesystem directory tree and was reconnected to the lost+found directory. The inode is assigned the name of its inode number (ino). If a lost+found directory does not exist, it is automatically created.

disconnected dir inode ino, moving to lost+found:As above only the inode is a directory inode. If a directory inode is attached to lost+found, all of its children (if any) stay attached to the directory and therefore get automatically reconnected when the directory is reconnected.

imap claims in-use inode ino is free, correcting imap:The inode allocation map thinks that inode ino is free whereas examination of the inode indicates that the inode may be in use (although it may be disconnected). The program updates the inode allocation map.

imap claims free inode ino is in use, correcting imap:The inode allocation map thinks that inode ino is in use whereas examination of the inode indicates that the inode is not in use and therefore is free. The program updates the inode allocation map.

resetting inode ino nlinks from x to y:The program detected a mismatch between the number of valid directory entries referencing inode ino and the number of references recorded in the inode and corrected the the number in the inode.

fork-type: fork in ino ino claims used block bno

inode ino - bad extent :An extent record in the blockmap of inode ino claims blocks that are out of the legal range of the filesystem. The message supplies the start, end, and file offset of the extent. The message is slightly different if the extent is a real-time (rt) extent.

bad fork-type fork in inode ino: There was something structurally wrong or inconsistent with the data structures that map offsets to filesystem blocks.

cleared inode ino:There was something wrong with the inode that was uncorrectable so the program freed the inode. This usually happens because the inode claims blocks that are used by something else or the inode itself is badly corrupted. Typically, this message is preceded by one or more messages indicating why the inode needed to be cleared.

bad attribute fork in inode ino, clearing attr fork:There was something wrong with the portion of the inode that stores XFS attributes (the attribute fork) so the program reset the attribute fork. As a result of this, all attributes on that inode are lost.

correcting nextents for inode ino, was x - counted y:The program found that the number of extents used to store the data in the inode is wrong and corrected the number. The message refers to nextents if the count is wrong on the number of extents used to store attribute information.

entry name in dir dir_ino not consistent with .. value (xxxx) in dir ino ino, junking entry name in directory inode dir_ino:The entry name in directory inode dir_ino references a directory inode ino. However, the .. entry in directory ino does not point back to directory dir_ino, so the program deletes the entry name in directory inode dir_ino. If the directory inode ino winds up becoming a disconnected inode as a result of this, it is moved to lost+found later.

entry name in dir dir_ino references already connected dir ino ino, junking entry name in directory inode dir_ino: The entry name in directory inode dir_ino points to a directory inode ino that is known to be a child of another directory. Therefore, the entry is invalid and is deleted. This message refers to an entry in a small directory. If this were a large directory, the last phrase would read "will clear entry".

entry references free inode ino in directory dir_ino, will clear entry:An entry in directory inode dir_ino references an inode ino that is known to be free. The entry is therefore invalid and is deleted. This message refers to a large directory. If the directory were small, the message would read "junking entry ...".

一致性检查日志如下(步骤)
[root@192 ~]# xfs_repair /dev/sdb1

Phase 1 - find and verify superblock...

Phase 2 - using internal log

    - zero log...

    - scan filesystem freespace and inode maps...

    - found root inode chunk

Phase 3 - for each AG...

    - scan and clear agi unlinked lists...

    - process known inodes and perform inode discovery...

    - agno = 0

    - agno = 1

    - agno = 2

    - agno = 3

    - process newly discovered inodes...

Phase 4 - check for duplicate blocks...

    - setting up duplicate extent list...

    - check for inodes claiming duplicate blocks...

    - agno = 0

    - agno = 1

    - agno = 2

    - agno = 3

Phase 5 - rebuild AG headers and trees...

    - 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...

done

其它
3. 执行xfs_repair -n,检查文件系统是否损坏,如何损坏会列出将要执行的操作

执行xfs_repair -n,检查文件系统是否损坏,如何损坏会列出将要执行的操作

  1. 执行xfs_repair修复文件系统

xfs_repair /dev/sdd (ext系列工具为fsck)

  1. 最后方法:损失部分数据的修复方法

根据打印消息,修复失败时:

先执行xfs_repair -L /dev/sdd(清空日志,会丢失文件),再执行xfs_repair /dev/sdd,再执行xfs_check /dev/sdd 检查文件系统是否修复成功。

说明:-L是修复xfs文件系统的最后手段,慎重选择,它会清空日志,会丢失用户数据和文件。

备注:在执行xfs_repair操作前,最好使用xfs_metadump工具保存元数据,一旦修复失败,最起码可以恢复到修复之前的状态。

参考
https://www.linux.org/docs/man8/xfs_repair.html

与[转帖]xfs_respair一点理解相似的内容:

[转帖]xfs_respair一点理解

xfs_respair一点理解 robot_test_boy IP属地: 江苏 0.276 2020.08.29 20:05:38 字数 2,449 阅读 2,485 上次学习了xfs文件系统,里边大致提了下xfs_respair怎么使用的,但是xfs_respair具体干嘛的并不清楚。 xfs_r

[转帖]xfs_repair命令详解

https://bbs.qunyingkeji.com/2052/ 1.现状 目前网上出现大量的主机输入输出错误,原因是由于主机文件系统损坏。一线人员大部分采用的是umont 和 mount的方式恢复,这种恢复方式不能真正修复已经损坏的文件系统,在后续使用过程中,仍然会再次出现主机端输入输出错误。

[转帖]xfs_repair命令详解

https://bbs.qunyingkeji.com/2052/ 1.现状 目前网上出现大量的主机输入输出错误,原因是由于主机文件系统损坏。一线人员大部分采用的是umont 和 mount的方式恢复,这种恢复方式不能真正修复已经损坏的文件系统,在后续使用过程中,仍然会再次出现主机端输入输出错误。

[转帖]Linux磁盘格式化(mkfs、mkfs.xfs、mkfs.ext4)、Linux文件系统的校验(xfs_repair、fsck_ext4)

https://blog.csdn.net/qq_41453285/article/details/86822769 一、mkfs命令磁盘分区完毕后自然就是要进行文件系统的格式化格式化其实就是创建文件系统。命令就是 >mkfs(make fileststem),这个命令只是个综合命令。它会调用正确的

[转帖]XFS文件系统 inodes异常

https://www.jianshu.com/p/f5763e4d7e5b 异常服务器 [sysadmin@VM_21_14_centos tomcat]$ df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/vgd

[转帖]MySQL Performance : XFS -vs- EXT4 Story

http://dimitrik.free.fr/blog/posts/mysql-80-perf-xfs-vs-ext4.html 2020-05-13 22:15 | MySQL, Performance, InnoDB, Benchmarks, DoubleWrite, XFS, EXT4 by

[转帖]磁盘读速度巨慢使用arcconf工具调整后的二次优化

情况叙述:lvm文件系统出现损坏,格式为xfs,磁盘修复失败后该节点需要重新格式化处理,格式化后重新划分pv,vg,lv,做完之后应用反应读写的速度达不到应用使用的要求,与正常的相比速度不稳定 现象:time和dd测试速度后发现写的速度为10-20MB/s 解决1:yy3:~ # chmod +x

[转帖]

Linux ubuntu20.04 网络配置(图文教程) 因为我是刚装好的最小系统,所以很多东西都没有,在开始配置之前需要做下准备 环境准备 系统:ubuntu20.04网卡:双网卡 网卡一:供连接互联网使用网卡二:供连接内网使用(看情况,如果一张网卡足够,没必要做第二张网卡) 工具: net-to

[转帖]

https://cloud.tencent.com/developer/article/2168105?areaSource=104001.13&traceId=zcVNsKTUApF9rNJSkcCbB 前言 Redis作为高性能的内存数据库,在大数据量的情况下也会遇到性能瓶颈,日常开发中只有时刻

[转帖]ISV 、OSV、 SIG 概念

ISV 、OSV、 SIG 概念 2022-10-14 12:29530原创大杂烩 本文链接:https://www.cndba.cn/dave/article/108699 1. ISV: Independent Software Vendors “独立软件开发商”,特指专门从事软件的开发、生产、