Chinaunix首页 | 论坛 | 博客
  • 博客访问: 133116
  • 博文数量: 53
  • 博客积分: 121
  • 博客等级: 入伍新兵
  • 技术积分: 570
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-04 10:59
文章分类
文章存档

2020年(1)

2013年(48)

2012年(4)

我的朋友

分类: 服务器与存储

2012-09-25 14:32:18

#去年的一个CASE 这里拿出来分享一下.
#2011_12_07   星期三   add by greshem
#花费: 4h
同事的移动硬盘的一个分区坏了 最近的工作的东西都在里面.
1. windows 下 ntfs 的一个分区不能读出,  在windows磁盘工具 里面 点击不能进去 可以看到分区
2. 接入到linux
    cat /dev/sdb4  > /dev/null  数据都可以读取到
    dmesg |grep ata 也没有发现有 硬盘的 有任何的坏道 认定为 ntfs  文件系统损坏
    而不是 分区表被破坏的问题了.
3. 无论怎么样 首先 把 硬盘分区的镜像拷贝出来, linux 下用 dd_rescue ddrescue 都可以, 之后要在磁盘镜像文件的基础上 做数据修复.
4. linux ntfs-3g  挂载首先提示 用windows 下的chkdisk /f 的方式去修复 ntfs 分区, 再跑到windows 下, 试了一下  微软的这个工具直接提示失败了,
    windows 下没有任何办法了.

3. 再到linux 下 用ntfs-3g  挂载  提示错误  用任何以ntfs 的工具都会提示  

打印信息是:  

ntfs_mst_post_read_fixup: magic: 0x44414142  size: 1024  usa_ofs: 21333  usa_count: 65535: 无效的参数
Record 1 has no FILE magic (0x44414142)
Failed to open inode $MFTMirr: 输入/输出错误
Failed to load $MFTMirr: 输入/输出错误
Failed to mount 'generbing_sdb6.img': 输入/输出错误
NTFS is inconsistent. Run chkdsk /f on Windows then reboot it TWICE!
The usage of the /f parameter is very IMPORTANT! No modification was
made to NTFS by this software.
Failed to open 'generbing_sdb6.img'

4. 看来 主要的问题在于mftmirr 的文件 , 在ntfs 里面 mft 文件才是最重要的, mftmirr 只是用来做相互校验的工具的地方。
    现在看看 究竟什么地方会 报 以上的错误 再定位到校验mftmirr文件的堆栈
5. yum  ntfs-3g 的debuginfo 的文件 不过不幸的是 最后发行的ntfs-3g 的软件包
    被优化过了 不能源代码调试
6.  找出f13 的ntfs-3g 的 代码 , 把所有设计到的 优化的编译选项去掉, gcc 里面就是 把-O2 去掉
7.  ntfs_mst_post_read_fixup: magic: 0x44414142  size: 1024  usa_ofs: 21333  usa_count: 65535: 无效的参数
    在ntfs 文件系统里面  0x44414142   是bad_cluster 的意思, 这个文件是没用的,
    mftmirror 算在ntfs 中比较重要的文件 现在标记已经是没用了 一盘是断电造成了,
    问了一下 耿二斌 原来 卸载磁盘的时候 卸载不掉 直接把移动硬盘给拔了.
8. 最后整理出来 出错的整个堆栈是
    
最后问题的堆栈是:
#0  ntfs_mst_post_read_fixup (b=0x60f880, size=1024) at mst.c:62
#1  0x00007ffff7d747e0 in ntfs_attr_mst_pread (na=, pos=, bk_cnt=, bk_size=1024, dst=0x60f880)
    at attrib.c:2549
#2  0x00007ffff7d8b818 in ntfs_mft_records_read (vol=, mref=, count=1, b=) at mft.c:106
#3  0x00007ffff7d8b9ba in ntfs_mft_record_read (vol=0x60e250, mref=1, mrec=0x60f7f8, attr=0x0) at ../include/ntfs-3g/mft.h:56
#4  ntfs_file_record_read (vol=0x60e250, mref=1, mrec=0x60f7f8, attr=0x0) at mft.c:294
#5  0x00007ffff7d869cf in ntfs_inode_real_open (vol=0x60e250, mref=1) at inode.c:176
#6  ntfs_inode_open (vol=0x60e250, mref=1) at inode.c:482
#7  0x00007ffff7d98c9e in ntfs_mftmirr_load (dev=, flags=) at volume.c:418
#8  ntfs_volume_startup (dev=, flags=) at volume.c:595
#9  0x00007ffff7d99039 in ntfs_device_mount (dev=, flags=268435457) at volume.c:871
#10 0x00007ffff7d99fd1 in ntfs_mount (name=, flags=268435457) at volume.c:1304
#11 0x00000000004068bb in utils_mount_volume (device=0x7fffffffe7df "generbing_sdb6.img", flags=268435457) at utils.c:283
#12 0x0000000000405562 in main (argc=4, argv=0x7fffffffe548) at ntfsinfo.c:229


     和个人猜想的差不多 , 对mftmirror 进行处理校验的时候 mftmirror 文件校验错误导致,  使磁盘不能挂载
    想到既然是数据恢复了 , 假如 对 ntfs 镜像  进行读操作 , 那么mftmirror 整个文件系统中不会用到 , 只要注释掉ntfs-3g 里面对于mftmirror的相关代码 就可以用ntfs-3g 挂出来了.
    果然 花了45分钟的时间 把涉及到的 一些代码 注释掉 , 最后又涉及到了一个 ntfs $VOLUME 的文件  代码中也注释掉, 应该对于ntfs文件系统的只读挂载也没有什么影响.
    编译成功之后  ntfs-3g -o ro  只读挂载的选项添加之后  ntfs 的镜像挂出来了, 数据恢复成功.
########################################################################

阅读(1353) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~