美文网首页
xfs_respair一点理解

xfs_respair一点理解

作者: robot_test_boy | 来源:发表于2020-08-29 20:05 被阅读0次

上次学习了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,检查文件系统是否损坏,如何损坏会列出将要执行的操作

4. 执行xfs_repair修复文件系统

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

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

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

先执行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文件系统,里边大致提了下xfs_respair怎么使用的,但是xfs_respair具体干嘛的并不...

  • 对addChildViewController的一点理解

    对addChildViewController的一点理解 对addChildViewController的一点理解

  • 一点理解

    昨天去面了一家民企,一家快速扩张的地产企业,和我谈话的是一位刚刚走出的央企人事。谈了一个多小时,面谈全程无感。倒是...

  • 一点理解

    当你选择自动去认识一个人,并坦白自己的一切,并且期望这个人能够接纳自己的一切,这种交友的方式本身就是一种错误,别人...

  • 一点理解

    更年轻的时候,喜欢公主范儿或娃娃装的装扮,有点小花边,蝴蝶结修饰的服装,觉得甜美又清新。 年龄大了,觉得穿衣打扮的...

  • 一点理解

    “如果最伟大的金融智慧与自我理解不匹配,它就什么都不是。” 我们不能看到别人什么赚钱就去投什么,因为外行看着只是表...

  • 多一点理解

    论理解与否,生命中中有很多过客,对于我现在来讲,过客其实就代表了没有耐心,没有坚持,亦比较任性,没有任何东西比时间...

  • this的一点理解

    1. this既不指向函数自身也不只指向函数的词法作用域。 2. this实际上是在函数被调用时发生的绑定,它的上...

  • 多一点理解

    昨天,我跟父母大吵了一架。为什么会吵了一架呢? 因为“作业”。昨天晚上我写完作业后就休息了,但是又怕唠叨我不写作...

  • 多一点理解

    你调皮、倔强、脾气暴躁,你喜欢打人,你讨厌做作业,你好像一点也不像个乖孩子,但是,你的每一个行为背后,都有着自己的...

网友评论

      本文标题:xfs_respair一点理解

      本文链接:https://www.haomeiwen.com/subject/fxuwjktx.html