linux 文件系统故障

本文详细描述了一次因停电导致CentOS服务器磁盘出现Input/output error的问题及解决方案。故障表现为部分用户登录异常和/home目录访问错误。通过推测磁盘老化或文件系统损坏为可能原因,采用fsck和xfs_repair工具进行修复,最终恢复正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

现象描述:系统是centos,一次停电导致服务器关机。开机后,输入正确的密码,界面一闪而过,又是要接着输入密码,也不提示我密码错误。当我换到命令行下使用logoin登录时,也是这种情况,只不过这里一直是让我输入用户名和密码两种。

当我使用root用户登录时,一切正常,当使用新建的其他用户登录时,又一切很正常了

进入/home 目录下,执行ls  结果出现:Input/output error 

进入其他目录比如/var 目录执行是正常的

1,推测原因:磁盘老化导致坏道,异常操作导致文件node错乱、文件损坏等
2,修复方法:软件修复,单不能保证修复所有的错误。修复后如果一段时间内再次发生,请考虑磁盘质量问题。
修复过程:
1 df -TH #记录目标磁盘的类型,如ext2、ext3.记录挂在盘和挂在目录。如:/dev/sda3 /disk3
2 umount /dev/sda3  #取消挂载,如提示设备忙,请执行:  fuser -km /dev/sda3
3 fsck -t ext2 -y /dev/sda3#修复。"ext2"是第一步查看的磁盘类型。
4 mount /dev/sda3 /disk3/  #完成挂载
5 reboot #建议重启。
 


如果是xfs文件系统:

修改包括三步:卸载,修复和检查重启

1)umount /dev/mapper/centos-home

 

2) xfs_repair /dev/mapper/centos-home Phase 1 - find and verify superblock... 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 re-running xfs_repair. 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 of the filesystem before doing this.

报错,提示使用-L参数:

xfs_repair -L /dev/vdb 
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 11 is 7499 in ag 3 (inode=805313867)
sb_icount 7296, counted 13184
sb_ifree 111, counted 644
sb_fdblocks 78500862, counted 59430965
        - 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 = 3
        - agno = 2
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 805313867, moving to lost+found
Phase 7 - verify and correct link counts...
Maximum metadata LSN (815:101693) is ahead of log (1:2).
Format log to cycle 818.
done

修复成功。

3) 再次挂载:mount /dev/mapper/centos-home /home

df -h  确认挂载成功

4) 重启一切正常

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fish_study_csdn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值