语言入口:简体中文 | English | 北亚博客
 
    
 
北亚Linux数据恢复

首席工程师:张宇

手机:18600440055

座机:4006-505-646-806

传真:4006-505-646-810

Email:zy@frombyte.com

地址:北京市海淀区永丰基地丰慧中路7号新材料创业大厦B座205室
QQ:免费咨询
当前位置:首页>>Linux修复知识>>Linux超级块修复>>正文
Linux修复知识

Linux 系统 ext3文件系统超级块损坏修复

1,一服务器/dev/sdb文件系统损坏,重启后系统启不来,进入单用户模式fsck无法修复,把/etc/fstab中的/dev/sdb

注释掉后,系统成功起来。
 
2,mount挂载/dev/sdb提示bad superblock 错误,无法正常挂载:
[root@localhost ~]# mount /dev/sdb /test
mount: wrong fs type, bad option, bad superblock on /dev/sdb,
       or too many mounted file systems
3,尝试直接指定备用超级块来挂载分区。通过mkfs -n可以查看到备份超级块的位置:
[root@localhost ~]# mkfs.ext3 -n /dev/sdb
mke2fs 1.35 (28-Feb-2004)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
365854720 inodes, 731688960 blocks
36584448 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
22330 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848, 512000000, 550731776, 644972544
也可以通过dumpe2fs查看备份超级块的位置:
[root@localhost ~]# dumpe2fs /dev/sdb | grep –before-context=1 superblock
dumpe2fs 1.35 (28-Feb-2004)
Group 0: (Blocks 0-32767)
  Primary superblock at 0, Group descriptors at 1-175

Group 1: (Blocks 32768-65535)
  Backup superblock at 32768, Group descriptors at 32769-32943

Group 3: (Blocks 98304-131071)
  Backup superblock at 98304, Group descriptors at 98305-98479

Group 5: (Blocks 163840-196607)
  Backup superblock at 163840, Group descriptors at 163841-164015

Group 7: (Blocks 229376-262143)
  Backup superblock at 229376, Group descriptors at 229377-229551

Group 9: (Blocks 294912-327679)
  Backup superblock at 294912, Group descriptors at 294913-295087

Group 25: (Blocks 819200-851967)
  Backup superblock at 819200, Group descriptors at 819201-819375

Group 27: (Blocks 884736-917503)
  Backup superblock at 884736, Group descriptors at 884737-884911

Group 49: (Blocks 1605632-1638399)
  Backup superblock at 1605632, Group descriptors at 1605633-1605807

Group 81: (Blocks 2654208-2686975)
  Backup superblock at 2654208, Group descriptors at 2654209-2654383

Group 125: (Blocks 4096000-4128767)
  Backup superblock at 4096000, Group descriptors at 4096001-4096175

Group 243: (Blocks 7962624-7995391)
  Backup superblock at 7962624, Group descriptors at 7962625-7962799
4,用查看到的备份超级块来挂载/dev/sdb,也无法成功:
[root@localhost ~]# mount -o sb=32768 /dev/sdb /test
mount: wrong fs type, bad option, bad superblock on /dev/sdb,
       or too many mounted file systems
分区情况如下:
[root@localhost ~]# fdisk -l
Disk /dev/sda: 998.9 GB, 998999326720 bytes
255 heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          16      128488+  83  Linux
/dev/sda2              17        6390    51199155   83  Linux
/dev/sda3            6391       12764    51199155   83  Linux
/dev/sda4           12765      121454   873052425    5  Extended
/dev/sda5           12765       13796     8289508+  82  Linux swap
/dev/sda6           13797      121454   864762853+  83  Linux
Disk /dev/sdb: 2996.9 GB, 2996997980160 bytes
255 heads, 63 sectors/track, 364364 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn’t contain a valid partition table
[root@localhost ~]# parted /dev/sdb
GNU Parted 1.6.19
Copyright (C) 1998 - 2004 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even

the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more

details.
Using /dev/sdb
(parted) print                                                          
Disk geometry for /dev/sdb: 0.000-2858160.000 megabytes
Disk label type: loop
Minor    Start       End     Filesystem  Flags
1          0.000 2858160.000  ext3      
(parted) quit                                                           
Information: Don’t forget to update /etc/fstab, if necessary. 
5,尝试用备份超级块去fsck修复分区,报“illegal bitmap block”错误,也无法成功:
[root@localhost ~]# fsck.ext3 -b 32768 /dev/sdb
e2fsck 1.35 (28-Feb-2004)
Block bitmap for group 4992 is not in group.  (block 809140608)
Relocate<y>? yes
Inode bitmap for group 4992 is not in group.  (block 5385)
Relocate<y>? yes
Inode table for group 4992 is not in group.  (block 1295485238)
WARNING: SEVERE DATA LOSS POSSIBLE.
Relocate<y>? yes
Block bitmap for group 4993 is not in group.  (block 0)
Relocate<y>? yes
Inode bitmap for group 4993 is not in group.  (block 0)
Relocate<y>? yes
Inode bitmap for group 21631 is not in group.  (block 171349112)
Relocate<y>? cancelled!
Inode table for group 21631 is not in group.  (block 0)
WARNING: SEVERE DATA LOSS POSSIBLE.
Relocate<y>? cancelled!
fsck.ext3: e2fsck_read_bitmaps: illegal bitmap block(s) for /dev/sdb
[root@localhost ~]# fsck.ext3 -b 163840 /dev/sdb
e2fsck 1.35 (28-Feb-2004)
Block bitmap for group 4992 is not in group.  (block 809140608)
Relocate<y>? yes
Inode bitmap for group 4992 is not in group.  (block 5385)
Relocate<y>? cancelled!
Inode table for group 4992 is not in group.  (block 1295485238)
WARNING: SEVERE DATA LOSS POSSIBLE.
Relocate<y>? cancelled!
Inode bitmap for group 21631 is not in group.  (block 171349112)
Relocate<y>? cancelled!
Inode table for group 21631 is not in group.  (block 0)
WARNING: SEVERE DATA LOSS POSSIBLE.
Relocate<y>? cancelled!
fsck.ext3: e2fsck_read_bitmaps: illegal bitmap block(s) for /dev/sdb
 
6,直接fsck -y修复分区,也是报一样的错误:
[root@localhost ~]# fsck.ext3 -y /dev/sdb
e2fsck 1.35 (28-Feb-2004)
Group descriptors look bad… trying backup blocks…
Block bitmap for group 4992 is not in group.  (block 809140608)
Relocate? yes
Inode bitmap for group 4992 is not in group.  (block 5385)
Relocate? yes
Inode table for group 4992 is not in group.  (block 1295485238)
WARNING: SEVERE DATA LOSS POSSIBLE.
Relocate? yes
Block bitmap for group 4993 is not in group.  (block 0)
Relocate? yes
Inode bitmap for group 4993 is not in group.  (block 0)
Relocate? yes
Inode table for group 4993 is not in group.  (block 567580784)
WARNING: SEVERE DATA LOSS POSSIBLE.
Relocate? yes
Block bitmap for group 4994 is not in group.  (block 0)
Relocate? yes
Block bitmap for group 21630 is not in group.  (block 0)
Relocate? yes
Inode bitmap for group 21630 is not in group.  (block 0)
Relocate? yes
Inode table for group 21630 is not in group.  (block 0)
WARNING: SEVERE DATA LOSS POSSIBLE.
Relocate? yes
Block bitmap for group 21631 is not in group.  (block 0)
Relocate? yes
Inode bitmap for group 21631 is not in group.  (block 171349112)
Relocate? yes
Inode table for group 21631 is not in group.  (block 0)
WARNING: SEVERE DATA LOSS POSSIBLE.
Relocate? yes
fsck.ext3: e2fsck_read_bitmaps: illegal bitmap block(s) for /dev/sdb
7,终极大法,用mke2fs -S重新生成超级块(注:此为实在没办法才执行的,不成功的话则全部数据会有丢失的可能),

修复成功了!!
[root@localhost ~]# mke2fs -S /dev/sdb
mke2fs 1.35 (28-Feb-2004)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
365854720 inodes, 731688960 blocks
36584448 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
22330 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848, 512000000, 550731776, 644972544
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
 
8,终于可以将分区挂载上了:
[root@localhost ~]# mount /dev/sdb /test
9,用tune2fs -l查看/dev/sdb,发现状态为:not clean with errors,浏览文件发现其中还是有很多文件是损坏的:
[root@localhost ~]# tune2fs -l /dev/sdb
tune2fs 1.35 (28-Feb-2004)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          2f3e8c46-64c0-4346-b7f6-edcfd457617a
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      resize_inode filetype sparse_super
Default mount options:    (none)
Filesystem state:         not clean with errors
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              365854720
Block count:              731688960
Reserved block count:     36584448
Free blocks:              720188790
Free inodes:              365854720
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      849
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16384
Inode blocks per group:   512
Filesystem created:       Fri Feb 18 14:37:14 2011
Last mount time:          Fri Feb 18 14:37:33 2011
Last write time:          Fri Feb 18 14:37:33 2011
Mount count:              1
Maximum mount count:      39
Last checked:             Fri Feb 18 14:37:14 2011
Check interval:           15552000 (6 months)
Next check after:         Wed Aug 17 14:37:14 2011
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Default directory hash:   tea
Directory Hash Seed:      72bc7ce8-d9db-40c4-8ee8-85e169dd4bc5
 
10,只有再用fsck修复下/dev/sdb,分区2T多,修复了9个小时:
[root@localhost ~]# fsck.ext3 -y /dev/sdb
e2fsck 1.35 (28-Feb-2004)
/dev/sdb contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Journal inode is not in use, but contains data.  Clear? yes
Inode 177963137 is in use, but has dtime set.  Fix? yes
Inode 177963137 has imagic flag set.  Clear? yes
Inode 177963147 is in use, but has dtime set.  Fix? yes
Inode 177963147 has imagic flag set.  Clear? yes
Inode 177963155 is in use, but has dtime set.  Fix? yes
Inode 177963155 has imagic flag set.  Clear? yes
Inode 177963156 is in use, but has dtime set.  Fix? yes
Inode 177963156, i_blocks is 4294967295, should be 0.  Fix? yes
Inode 177963155 has compression flag set on filesystem without compression support.  Clear? yes
Inode 177963155 has INDEX_FL flag set but is not a directory.
11,修复完成后,/dev/sdb分区能够正常使用,此时发现文件系统变成ext2的了:
[root@localhost ~]# df -hT
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda3     ext3     49G   36G   11G  78% /
/dev/sda6     ext3    812G  750G   22G  98% /bk
/dev/sda1     ext3    122M   13M  103M  12% /boot
none         tmpfs    3.9G     0  3.9G   0% /dev/shm
/dev/sda2     ext3     49G  3.2G   43G   7% /opt
/dev/sdb      ext2    2.7T  2.3T  349G  87% /test

本新闻共2页,当前在第1页  1  2  

上一篇:配置安全的SCO UNIX网络系统
下一篇:讲解Unix内核超级块知识
JFS文件系统简介
XFS文件系统简介
Reiserfs文件系统简介
EXT3文件系统简介
常见Linux文件系统简介
GRUB简介与配置
LILO的使用和配置
Linux单用户模式维护系统
引导加载程序简介
重置Linux用户口令
  版权所有@北京北亚宸星科技有限公司   京ICP备09039053号    
  总部电话:(010)82488636  中国·北京·海淀区永丰基地丰慧中路7号新材料创业大厦B座205室              站点地图   联系我们  RSS阅读