1. ホーム
  2. リナックス

xfsファイルシステム修復

2022-02-28 03:31:49
<パス

1. エラーの説明

CentOS 7 システムを起動すると、GUI が進行していることがわかり、次のエラーが報告されます。

Error getting authority: Error initializing authority:
Could not connect: No such file or directory (g-io-error-quark, 1)


プロンプトに従う:システムにログインして journalctl -xb をクリックすると、システムログが表示されます。

使用方法 journalctl -xb コマンド

# journalctl -xb

# See the error on the error is about the I/O error, the first thought is not a disk problem, search /mount, press n step by step search, see if there are errors

<イグ

エラーメッセージが表示されます。 Failed to /mount /dev/sdb1

マウントに失敗しているのはディスクの不良ブロックに違いないので、まず/etc/fstabでそのブロックをコメントアウトして自動的にマウントできるようにします

2. 解決方法

2.1 設定ファイル /etc/fstab の修正

# vi /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon Jul 30 21:52:27 2018
# /etc/fstab
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=18e49f02-2719-4b91-aae0-dfb73e36d6bc /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
#/dev/sdb1 /data xfs defaults 0 0

2.2 OS を再起動して GUI にアクセスできるようにする

2.3 手動でディスクをマウントする

# mount /dev/sdb1 /data
mount: /dev/sdb1 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.


2.4 エラーメッセージに基づくディスクの修復(xfs_repair)

ディスクはxfs_repair形式なので、対応するrepairコマンドは

xfs_repair
# xfs_repair /dev/sdb1
Phase 1 - find and verify superblock...
bad primary superblock - bad magic number !!!

attempting to find secondary superblock...
..............................................

しばらく実行した後...

verified secondary superblock...
writing modified primary superblock
sb realtime bitmap inode 18446744073709551615 (NULLFSINO) inconsistent with calculated value 65
resetting superblock realtime bitmap ino pointer to 65
sb realtime summary inode 18446744073709551615 (NULLFSINO) inconsistent with calculated value 66
resetting superblock realtime summary ino pointer to 66
Phase 2 - using internal log
        - zero log...
ERROR: The filesystem has valuable metadata changes in a log which needs to be replayed.
Mount the filesystem to replay the log, and unmount it before
If you are unable to mount the filesystem, then use
If you are unable to mount the filesystem, then use the -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption -- please attempt a mount
Note that destroying the log may cause corruption -- please attempt a mount of the filesystem before doing this.


修復失敗のプロンプトが表示された場合は xfs_repair -L が、データ消失につながる可能性があります。

2.5 実行
xfs_repair -L
# xfs_repair -L /dev/sdb1
Phase 1 - find and verify superblock...
sb realtime bitmap inode 18446744073709551615 (NULLFSINO) inconsistent with calculated value 65
resetting superblock realtime bitmap ino pointer to 65
sb realtime summary inode 18446744073709551615 (NULLFSINO) inconsistent with calculated value 66
resetting superblock realtime summary ino pointer to 66
Phase 2 - using internal log
        - zero log...
ALERT: The filesystem has valuable metadata changes in a log which is being
ALERT: The filesystem has valuable metadata changes in a log which is being destroyed because the -L option was used.
        - scan filesystem freespace and inode maps...
agi unlinked bucket 1 is 6368769 in ag 2 (inode=73477633)
agi unlinked bucket 2 is 6368770 in ag 2 (inode=73477634)
agi unlinked bucket 3 is 6368771 in ag 2 (inode=73477635)
agi unlinked bucket 4 is 6368772 in ag 2 (inode=73477636)
agi unlinked bucket 15 is 53775 in ag 2 (inode=67162639)
agi unlinked bucket 16 is 53776 in ag 2 (inode=67162640)
agi unlinked bucket 17 is 53777 in ag 2 (inode=67162641)
agi unlinked bucket 21 is 53781 in ag 2 (inode=67162645)
sb_icount 0, counted 1024
sb_ifree 0, counted 185
sb_fdblocks 13100529, counted 9976617
        - 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 ...
disconnected inode 67162639, moving to lost+found
disconnected inode 67162640, moving to lost+found
disconnected inode 67162641, moving to lost+found
disconnected inode 67162645, moving to lost+found
disconnected inode 73477633, moving to lost+found
disconnected inode 73477634, moving to lost+found
disconnected inode 73477635, moving to lost+found
disconnected inode 7347763

2.6 実行
xfs_repair
# 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

修理に成功

2.7 手動マウント、/etc/fstab ファイルを変更する。

# mount /dev/sdb1 /data


# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Jul 30 21:52:27 2018
# /etc/fstab
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=18e49f02-2719-4b91-aae0-dfb73e36d6bc /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/sdb1 /data xfs defaults 0 0