linux文件系统损坏,导致系统无法启动解决办法

(2015-12-07 10:15:06)

标签:

故障诊断

系统损坏

文件系统

fsck

系统修复

1 概述

系统在断电,以及执行配置更新、软件升级、内核升级后都可能导致系统无法启动,常见的原因如下:

* 文件系统配置不当,例如/etc/fstab、/etc/inittab文件配置错误或丢失。

* 内核文件丢失或崩溃。

* 系统引导程序出现问题,例如grub丢失或顺坏。

* 系统硬件故障。

2 解决方法

当前linux普遍使用ext3、ext4文件系统,这两种文件系统都是具有日志记录功能的日志文件系统,可以进行简单的容错和纠错。日志系统并不是把数据实时写入磁盘,而是定期批量写入磁盘,对文件系统的所有读写操作都会实时记录到日志文件中,当系统发生断电等错误导致数据没有写入磁盘时,可以通过日志文件中的记录,回滚发生故障时的读写操作,保证数据的一致性。

checking root filesystem
/dev/sdb1 contains a file system with errors, check forced
/dev/sdb1:
Unattached inode 1842321623
/dev/sdb1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY
(i.e., without -a or -p options)
FAILED
/contains a file system with errors check forced
an eror occurred during the file system check
****dropping you to a shell;the system will reboot
****when you leave the shell
Press enter for maintenance
(or type Control-D to continue):
give root password for maintenance

通常遇到这个问题主要是系统突然断电,引起文件系统结构的不一致,一般情况下,使用fsck命令进行修复。

根据上面的错误提示,按下Control +

D组合键后系统自动重启,输入root密码后进行系统修复模式,在修复模式下,执行fsck命令,操作如下:

[root@localhost ~]# umount /dev/sdb1
[root@localhost ~]# fsck.ext4 -y /dev/sdb1 # 自动修复检测到的文件系统损坏
e2fsck 1.39 (29-May-2006)
/ contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Inode 6833812 ref count is 2, should be 1. Fix?
yes
Unattached inode 6833812
Connect to /lost+found? yes
Inode 6833812 ref count is 2, should be 1. Fix?
yes
Pass 5: Checking group summary information
Block bitmap differences: -(519--529) -9273
Fix? yes
…… ……
/: ***** FILE SYSTEM WAS MODIFIED *****
/: 19/128520 files (15.8% non-contiguous), 46034/514048
blocks

注意:在修复文件系统时,必须先卸载故障的磁盘分区,然后再执行fsck进行修复。在修复过程中,无法修复额数据会存放在文件系统的lost+found目录中。