linux 文件系统 corrupted,修复损坏linux 文件系统

原贴:http://www.linuxext.com/bbs/htm_data/14/0708/14411.html

修复损坏linux 文件系统

revised by woflman 2007.08.05

今天的我们早上我的服务器无法启动,停在检查

mail.wofman.com/var filesystem bad ,我的mail文件在此目录下;

Bad magic number in super_block while trying to open /var

***An error occured 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):

输入admai pass 后进入 (Repair filesystem)#

查看/etc/fstab 没有错误,

运行fsck -p /var

运行完毕有下面提示:

/dev/sda3 contains a file system with errors, check forced.

/dev/sda3: Inodes that were part of a corrupted orphan linked list found.

/dev/sda3: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.

(i.e., without -a or -p options)

运行fsck.ext3 -p /dev/sda3 ;未能修复

运行fsck.ext3 -y /dev/sda3 ; repair ok

;注意在修复其它filesystem时要umount掉运行该命令。

文件系统--fsck

指令:fsck

使用权限 : 超级使用者

使用方式 : fsck --help

fsck 1.35 (28-Feb-2004)

fsck.ext3: invalid option -- h

Usage: fsck.ext3 [-panyrcdfvstDFSV] [-b superblock] [-B blocksize]

[-I inode_buffer_blocks] [-P process_inode_size]

[-l|-L bad_blocks_file] [-C fd] [-j ext-journal]

[-E extended-options] device

Emergency help:

-p Automatic repair (no questions) ;自动修复

-n Make no changes to the filesystem ;模拟修复

-y Assume "yes" to all questions ;所有的问题都回答yes

-c Check for bad blocks and add them to the badblock list

;检查坏块,并记录下坏块列表

-f Force checking even if filesystem is marked clean

;对标记为“干净”的文件系统进行强制检查 v Be verbose ;详细信息

-b superblock Use alternative superblock

-B blocksize Force blocksize when looking for superblock

-j external-journal Set location of the external journal

-l bad_blocks_file Add to badblocks list

-L bad_blocks_file Set badblocks list

引用网上的一个例子 :

问题: SLES8 在mount盘阵的时候,出现

server1:/ # mount /dev/sde1 /foo

mount: wrong fs type, bad option, bad superblock on /dev/sde1,

or too many mounted file systems

的问题。请问这种问题怎么能解决呢?

回答:

这个错误信息标识 /dev/sde1 设备上的 ext3 文件系统的超级块损坏了,ext3 文件系统的元数据保存在超级块中。

ext3 文件系统还有一些备份的超级块,可以尝试用备份的超级块加载 ext3 文件系统和修复 ext3 文件系统。

备份的超级块信息可以通过以下命令获得,这个命令模拟 ext3 文件系统创建时的动作并打印出备份超级块的位置,给出的位置缺省是以4k为单位的,mount 在使用时需要为它提供以1k为单位的偏移,需要乘4:

注意!!!!!一定要使用'-n'作为参数模拟 ext3 文件系统的创建而不是真的创建 ext3 文件系统

# mkfs.ext3 -n /dev/hda7

mke2fs 1.38 (30-Jun-2005)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

2198880 inodes, 4393738 blocks

219686 blocks (5.00%) reserved for the super user

First data block=0

135 block groups

32768 blocks per group, 32768 fragments per group

16288 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000

使用备份的超级块来加载 ext3 文件系统的命令:

语法: mount.ext3 -o sb=n

# mount.ext3 -o sb=131072 /dev/hda7 /media/hda7

使用备份的超级块来修复 ext3 文件系统的命令

语法:fsck.ext3 -b superblock

# fsck.ext3 -b 32768 /dev/hda7