报错:
[root@localhost ~]# mount /dev/mapper/mpathd /data04/
mount: mount /dev/mapper/mpathd on /data04 failed: Structure needs cleaning
[root@localhost ~]# xfs_ncheck /dev/mapper/mpathd
Metadata corruption detected at xfs_agf block 0x1/0x200
xfs_ncheck: cannot init perag data (-117). Continuing anyway.
* ERROR: mismatched uuid in log
* SB : 281f884a-e5c5-41b2-98bf-3838498d822b
* log: 5197aaf5-4655-4e9e-9f3b-f98b035f1540
Metadata corruption detected at xfs_agi block 0x2/0x200
Metadata corruption detected at xfs_agfl block 0x3/0x200
Metadata corruption detected at xfs_allocbt block 0x8/0x1000
Metadata corruption detected at xfs_allocbt block 0x10/0x1000
Metadata corruption detected at xfs_inobt block 0x18/0x1000
Metadata corruption detected at xfs_agf block 0xa00001/0x200
Metadata corruption detected at xfs_agi block 0xa00002/0x200
Metadata corruption detected at xfs_agfl block 0xa00003/0x200
Metadata corruption detected at xfs_allocbt block 0xa00008/0x1000
Metadata corruption detected at xfs_allocbt block 0xa00010/0x1000
Metadata corruption detected at xfs_inobt block 0xa00018/0x1000
Metadata corruption detected at xfs_agf block 0x1400001/0x200
Metadata corruption detected at xfs_agi block 0x1400002/0x200
Metadata corruption detected at xfs_agfl block 0x1400003/0x200
Metadata corruption detected at xfs_allocbt block 0x1400008/0x1000
Metadata corruption detected at xfs_allocbt block 0x1400010/0x1000
Metadata corruption detected at xfs_inobt block 0x1400018/0x1000
Metadata corruption detected at xfs_agf block 0x1e00001/0x200
Metadata corruption detected at xfs_agi block 0x1e00002/0x200
Metadata corruption detected at xfs_agfl block 0x1e00003/0x200
Metadata corruption detected at xfs_allocbt block 0x1e00008/0x1000
Metadata corruption detected at xfs_allocbt block 0x1e00010/0x1000
Metadata corruption detected at xfs_inobt block 0x1e00018/0x1000
解释
xfs_ncheck /dev/mapper/vg-lv;echo $?
如果返回0表示正常不用修复,否则继续下面步骤。
解决方案:
先打磁盘快照!!
确保数据是安全的。
虚拟机做快照,存储打快照,物理机则通过dd导出
[root@aaroncentos79 ~]# xfs_db -x /dev/mapper/VG00-data
Metadata corruption detected at xfs_agf block 0x1/0x200
xfs_db: cannot init perag data (-117). Continuing anyway.
xfs_db> sb
xfs_db> p
magicnum = 0x58465342
blocksize = 4096
dblocks = 5242880
rblocks = 0
rextents = 0
uuid = 281f884a-e5c5-41b2-98bf-3838498d822b
logstart = 4194308
rootino = 64
rbmino = 65
rsumino = 66
rextsize = 1
agblocks = 1310720
agcount = 4
rbmblocks = 0
logblocks = 2560
versionnum = 0xb4a5
sectsize = 512
inodesize = 512
inopblock = 8
fname = "\000\000\000\000\000\000\000\000\000\000\000\000"
blocklog = 12
sectlog = 9
inodelog = 9
inopblog = 3
agblklog = 21
rextslog = 0
inprogress = 0
imax_pct = 25
icount = 64
ifree = 61
fdblocks = 5240296
frextents = 0
uquotino = 0
gquotino = 0
qflags = 0
flags = 0
shared_vn = 0
inoalignmt = 4
unit = 0
width = 0
dirblklog = 0
logsectlog = 0
logsectsize = 0
logsunit = 1
features2 = 0x18a
bad_features2 = 0x18a
features_compat = 0
features_ro_compat = 0
features_incompat = 0x1
features_log_incompat = 0
crc = 0x17b087c3 (correct)
spino_align = 0
pquotino = 0
lsn = 0
meta_uuid = 00000000-0000-0000-0000-000000000000
xfs_db> write uuid 5197aaf5-4655-4e9e-9f3b-f98b035f1540
uuid = 5197aaf5-4655-4e9e-9f3b-f98b035f1540
xfs_db> agf
xfs_db> p
xfs_db> q
你会发现,我们修改的UUID,就是修改成了agf、agi、agfl里的UUID了
#不要使用xfs_repair /dev/mapper/VG00-data 除非没有其他办法了。
[root@aaroncentos79 ~]# mount /dev/mapper/VG00-data /mnt
This document (7018603) is provided subject to the disclaimer at the end of this document.
Environment
SUSE Linux Enterprise Server 12
Situation
# mount /dev/sdb /mnt/
mount: mount /dev/sdb on /mnt failed: Structure needs cleaning
and assuming that sdb contains a XFS Filesystem.
Resolution
To get the metadata, assuming /dev/sdb contains a XFS Filesystem, as root run the following command:
# /usr/sbin/xfs_metadump -aowg /dev/sdb /tmp/dump_xfs_meta
would be invoked. This results in a file /tmp/dump_xfs_meta containing the metadata and no Data Obfuscation.
This file cannot be used yet, but would have to be changed into a restore file with
# /usr/sbin/xfs_mdrestore /tmp/dump_xfs_meta /tmp/workable_xfs_dump
this new file, /tmp/workable_xfs_dump can be used safely for experiments and test and even be mounted and should exhibit the original error during a mount attempt.
# mount /tmp/workable_xfs_dump /mnt/
mount: mount /dev/loop0 on /mnt failed: Structure needs cleaning
but after a
# xfs_repair /tmp/workable_xfs_dump
in this example it can be mounted. And subsequent checked whether files and directories are still in place.
Additional Information
xfs_db -fx /tmp/workable_xfs_dump
then in the shell do
xfs_db> sb
xfs_db> p
and for example change the uuid with
xfs_db> write uuid 12345678
uuid = 20000000-0000-0000-0000-000000bc614e
xfs_db> q
which would then result in an error during mount
# mount /tmp/workable_xfs_dump /mnt/
mount: mount /dev/loop0 on /mnt failed: Structure needs cleaning
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.