博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
structure needs cleaning
阅读量:6800 次
发布时间:2019-06-26

本文共 5781 字,大约阅读时间需要 19 分钟。

 

If you're attempting to run , getting the error message that suggests mounting the filesystem to replay the log, and after mounting still receiving the same error message, you may need to perform a forced repair (using the -L flag with xfs_repair). This option should be a last resort.

For example, I'll use a case where I had a corrupt root partition on my CentOS 7 install. When attempting to mount the partition, I continually received the below error message:

mount: mount /dev/mapper/centos-root on /mnt/centos-root failed: Structure needs cleaning

Unfortunately, forcing a repair would involve zeroing out (destroying) the log before attempting a repair. When using this method, there is a potential of ending up with more corrupt data than initially anticipated; however, we can use the appropriate xfs tools to see what kind of damage may be caused before making any permanent changes.

Using  and , you can create a metadata image of the affected partition and perform the forced repair on the image rather than the partition itself. The benefits of this is the ability to see the damage that comes with a forced repair before performing it on the partition.

To do this, you'll need a decent sized USB or external hard drive. Start by mounting the USB drive - my USB was located at /dev/sdb1, yours may be named differently.

mkdir -p /mnt/usbmount /dev/sdb1 /mnt/usb

Once mounted, run xfs_metadump to create a copy of the partition metadata to the USB - again, your affected partition may be different. In this case, I had a corrupt root partition located at /dev/mapper/centos-root:

xfs_metadump /dev/mapper/centos-root /mnt/usb/centos-root.metadump

Next, you'll want to restore the metadata in to an image so that we can perform a repair and measure the damage.

xfs_mdrestore /mnt/usb/centos-root.metadump /mnt/usb/centos-root.img

I found that in rescue mode xfs_mdrestore is not available, and instead you'll need to be in rescue mode of a live CentOS CD.

Finally, we can perform the repair on the image:

xfs_repair -L /mnt/usb/centos-root.img

After the repair has completed and you've assessed the output and potential damage, you can determine as to whether you'd like to perform the repair against the partition.

To run the repair against the partition, simply run:

xfs_repair -L /dev/mapper/centos-root

Don't forget to check the other partitions for corruption as well. After the repairs, reboot the system and you should be able to successfully boot.

Remember that the -L flag should be used as a last resort where there are no other possible options to repair.

 

https://serverfault.com/questions/777299/proper-way-to-deal-with-corrupt-xfs-filesystems

https://serverfault.com/questions/851204/risk-of-not-repairing-structure-needs-cleaning-xfs-errors

 https://unix.stackexchange.com/questions/330742/cannot-remove-file-structure-needs-cleaning

http://xfs.9218.n7.nabble.com/mount-Structure-needs-cleaning-td2796.html

 

 

 

 

 

fsck -vcfy /dev/sda3 会清空数据。

 

我的移动硬盘也遇到这个问题,同样是XFS文件系统。在未挂载状态下试一试这个命令:# xfs_repair /dev/sdb1 /*后面跟目标驱动器路径*/如果提示log什么的有问题,则使用-L参数,这会重建log,然后再使用上面一条命令进行修复。#xfs_repair -L /dev/sdb1

 

1 执行debugfs -w /dev/sdb    (/dev/sdb出现 该情况文件所在的分区) -w says that partition will be opened in read-write mode.

2 mount /dev/sdb /mnt/other  挂载到mnt/other 目录下

3 执行 clri path/file    移除损坏文件节点 注意path/file 值的是相对路径 而不是/mnt/other/****

4 退出 debugfs 执行fsck -y /mnt/other   修复该分区

 

 

ext4文件系统,使用命令  fsck.ext4 /dev/md0 修复,

如果是xfs文件系统,使用命令 xfs_repair -L /dev/md0修复,

 

 

# mount /dev/sdb1 /disk2

mount: Structure needs cleaning

我用了下列的指令解決了. 雖然我不太清楚什麼東西導致它有問題 :

# xfs_repair -n /dev/sdb1

上面指令還不能完全解決

# xfs_check /dev/sdb1

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
re-running xfs_check. If you are unable to mount the filesystem, then use
the xfs_repair -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption — please attempt a mount
of the filesystem before doing this.

用 xfs_check 指令. 它建議我用 “xfs_repair -L ”

# xfs_repair -L /dev/sdb1

這樣弄玩之後. 在用 xfs_check 檢查一次

# xfs_check /dev/sdb1

就可以掛載了

# mount /dev/sdb1 /disk2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[root@pc4 ~]# mount /data2

mount: Structure needs cleaning

 

[root@pc4 ~]# xfs_repair -L /dev/vgcb0 

Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
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 16 is 252816 in ag 0 (inode=252816)
sb_icount 2977088, counted 2639872
sb_ifree 1752667, counted 1398980
sb_fdblocks 243437595, counted 241668641
        - found root inode chunk
Phase 3 - for each AG...
        - scan and clear agi unlinked lists...
        - process known inodes and perform inode discovery...
        - agno = 0
7ff4a425e700: Badness in key lookup (length)
bp=(bno 126400, len 16384 bytes) key=(bno 126400, len 8192 bytes)
        - 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 = 2
        - agno = 3
        - agno = 0
        - agno = 1
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 252816, moving to lost+found
Phase 7 - verify and correct link counts...
done
[root@pc4 ~]# 
[root@pc4 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             194G  5.2G  179G   3% /
tmpfs                  63G   72K   63G   1% /dev/shm
/dev/sda2             194M   32M  152M  18% /boot
/dev/sda4              20G  196M   19G   2% /tmp
/dev/vgca0            2.1T  1.2T  938G  55% /data1
[root@pc4 ~]# mount /data2

 

转载地址:http://nluwl.baihongyu.com/

你可能感兴趣的文章
红帽论坛北京站召开 设立亚太开放创新实验室
查看>>
Spark生态顶级项目汇总
查看>>
EF Core 2.1路线图:视图、GROUP BY和惰性加载
查看>>
NetBeans在Apache基金会取得的进展
查看>>
Netflix实时流处理平台Keystone介绍
查看>>
一文带你快速读懂.NET CLI
查看>>
深入探索JVM自动资源管理
查看>>
实现TeX的算法:回首编程技术的过去三十年
查看>>
re:Invent大会第四天:为什么Lambda值得你更多关注?
查看>>
B端大数据应用的架构实践与思考
查看>>
Cascade:自动化测试“旅程”
查看>>
2018年十大云宕机事故盘点:主流无一幸免!
查看>>
美团开源实时监控系统 CAT 3.0 发布:多语言客户端及多项性能提升
查看>>
开源项目koa-router被叫卖,周下载10W+只要5000美元
查看>>
360首席安全官谭晓生宣布离职
查看>>
微软正式发布Azure Functions 2.0
查看>>
Swift 4.2进入最后开发阶段,为Swift 5铺平道路
查看>>
爱立信电信软件的持续交付
查看>>
Oracle提醒Java开发者们,很快就没有浏览器可以运行Applets了
查看>>
《The Age of Surge》作者访谈
查看>>