解决‘$MFTMirr does not match $MFT (record 0)’

最近在ubuntu上COPY 文件到移动硬盘上(NTFS),中途挂掉,结果无法访问NTFS移动硬盘,

按照在墙外的某wordpress blog,解决了这个问题~

 

How to fix ‘$MFTMirr does not match $MFT (record 0)’

Sometimes, when you are executing a file transfer between your computer hard drive and an external drive and your computer shutdown for some reason (in my case, no battery/ac power) it’s pretty common to get some errors on external drives that uses NTFS as they file system.

The most common message is:

Error mounting: mount exited with exit code 13: $MFTMirr does not match $MFT (record 0).
Failed to mount ‘/dev/sdb3′: Input/output error
NTFS is either inconsistent, or there is a hardware fault, or it’s a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the ‘dmraid’ documentation
for more details.

One workaround for this issue is to do as the message says, boot on Windows and try to use the awesome NTFS tool that Windows offer. But a perfect solution for a Linux users is to use the ntfsprogs utility.

UPDATE: On some recent Linux releases, you need to install ntfs-3g utilties.  Try sudo apt-get install ntfs-3g or download from http://www.tuxera.com/community/ntfs-3g-download/

ntfsprogs is a suite of NTFS utilities based around a shared library. The tools are available for free and come with full source code.

  • mkntfs: Create an NTFS volume on a partition
  • ntfscat: Print a file on the standard output
  • ntfsclone: Efficiently backup/restore a volume at the sector level
  • ntfscluster: Given a cluster, or sector, find the file
  • ntfsfix: Forces Windows to check NTFS at boot time
  • ntfsinfo: Dump a file’s attributes, completely
  • ntfslabel: Display or set a volume’s label
  • ntfslib: Move all the common code into a shared library
  • ntfsls: List directory contents
  • ntfsresize: Resize an NTFS volume
  • ntfsundelete: Find files that have been deleted and recover them
  • ntfswipe: Write zeros over the unused parts of the disk
  • ntfsdefrag: Defragment files, directories and the MFT
  • ntfsck: Perform consistancy checks on a volume
  • nttools: Command-line tools to view/change an offline NTFS volume, e.g. ntfscp, ntfsgrep, ntfstouch, ntfsrm, ntfsrmdir, ntfsmkdir
  • ntfsdiskedit: Walk the tree of NTFS ondisk structures (and alter them)

Be careful with these utilities, they might damage the filesystem, or your hard disk !

With ntfsprogs installed (sudo apt-get install ntfsprogs) you should execute the following commands in a terminal:

sudo ntfsfix /dev/partitionName

After this command you should expect the following output:

~$ sudo ntfsfix /dev/sdb3
Mounting volume... FAILED
Attempting to correct errors...
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... FAILED
Correcting differences in $MFTMirr record 0...OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
NTFS volume version is 3.1.
NTFS partition /dev/sdb3 was processed successfully.

After this step you should be able to access your external drive partition as usual, mount or use nautilus to access your files.

Source:  http://gnuwin32.sourceforge.net/packages/ntfsprogs.htm

<think>嗯,用户想查找关于NTFS$MFT的模板或资源,特别是文件结构和格式的示例。我需要结合提供的引用资料来组织答案。首先,引用[1]提到MFT是NTFS的核心,每个文件和目录都有对应的entry,每个entry是1024字节,并且包含修正值。这应该是基本结构。引用[2]中的用户开发了一个工具查看MFT记录,说明实际应用中可能需要解析这些二进制数据,可能需要具体的字段定义。引用[4]提到了使用Python和Windows API获取磁盘信息,这可能和如何访问MFT有关。 首先,我应该解释MFT的基本结构,参考引用[1]中的描述,entry的固定大小和修正值部分。然后,给出具体的结构示例,可能需要结合引用[3]中的结构体,但注意引用[3]是关于WcifsPortMsgSetUnion的结构,可能不直接相关,但可以忽略。或者用户可能希望看到MFT entry的具体字段,如标准头、属性列表等。 接下来,用户可能需要资源或工具,比如解析MFT的工具,如引用[2]中的Qt工具,或者Python脚本示例。引用[4]中的Python代码示例可以用来展示如何访问卷信息,进而读取MFT。需要确保提供的代码示例正确,并且符合用户的需求。 可能还需要模板或结构体定义,例如MFT entry的数据结构,如标准头、属性类型、属性头等,这部分需要根据引用[1]中的表格,但用户提供的引用中没有详细表格,可能需要根据常识补充。例如,每个MFT entry可能包含标准头、属性列表,每个属性有类型码、长度、是否为常驻等。 另外,用户可能需要注意事项,比如直接访问MFT需要管理员权限,使用WinHex或磁盘编辑器等工具。最后,生成相关问题,如解析MFT的步骤、属性类型、修复损坏的MFT等。</think>### NTFS $MFT 文件结构解析 #### 1. **MFT 基础结构** NTFS$MFT(主文件表)是文件系统的核心元数据文件,每个文件和目录对应一个MFT条目(Entry)。每个Entry固定大小为1024字节(由启动扇区定义),包含以下核心字段[^1]: - **修正值**:每个Entry末尾的两个字节用于校验和恢复。 - **标准头**:包含Entry状态(如是否在用、是否为目录等)、属性列表偏移量等。 - **属性列表**:存储文件或目录的实际元数据(如文件名、数据流、时间戳等)。 #### 2. **MFT Entry 示例结构 以下是简化的MFT Entry数据结构模板(以16进制解析为例): ```plaintext Offset 长度 描述 0x00 4 固定签名 "FILE" 0x04 2 更新序列号偏移 0x06 2 更新序列号数量 0x08 8 $LogFile序列号(LSN) 0x10 2 序列号(用于硬链接) 0x12 2 硬链接数 0x14 2 属性列表偏移 0x16 2 标志(如是否目录) 0x18 4 实际Entry大小 0x1C 4 分配Entry大小 0x20 8 基文件记录(用于扩展Entry) ... 变长 属性列表(如$STANDARD_INFORMATION、$FILE_NAME等) ``` #### 3. **关键属性类型 每个属性以**属性头**开始,包含类型码、长度、是否为常驻(Resident/Non-Resident)等字段。常见属性: - **$STANDARD_INFORMATION**:创建/修改时间、权限。 - **$FILE_NAME**:文件名、父目录MFT编号。 - **$DATA**:文件内容流(可能分片存储)。 - **$ATTRIBUTE_LIST**:若属性跨多个Entry,记录扩展位置[^1]。 #### 4. **工具与资源 - **手动解析工具**: - **WinHex**:支持直接查看磁盘扇区中的MFT Entry(需管理员权限)。 - **NTFSWalker**:开源工具,可提取MFT条目并解析属性。 - **编程示例**(参考引用[2][^4]): ```python import win32file # 获取卷句柄(需管理员权限) volume = r"\\.\C:" handle = win32file.CreateFile(volume, win32file.GENERIC_READ, win32file.FILE_SHARE_READ | win32file.FILE_SHARE_WRITE, None, win32file.OPEN_EXISTING, 0, None) # 读取$MFT的起始簇(通过NTFS元文件定位) # 具体实现需结合NTFS的$DATA属性解析 ``` #### 5. **注意事项 - **直接访问MFT**:需通过物理磁盘或卷句柄(如`\\.\C:`),且需要管理员权限。 - **数据恢复**:非驻留属性(Non-Resident)可能分散存储,需通过“数据运行列表”(Data Run List)定位簇位置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值