碎片化檔案復原測試:資料剝離結果

碎片化檔案恢復測試

A fragmented file recovery test should first establish where each part of a file is stored. On NTFS, the nonresident $DATA attribute can describe that layout through Data Runs. We compare a contiguous PNG with the same PNG spread across three extents, then show why reading the fragmented layout as consecutive clusters fails. Finally, we follow the retained cluster mapping and verify the reconstructed bytes using SHA-256 and PNG CRC checks.

目錄

Research Question: What Changes When a File Is Fragmented?

A file may be logically continuous even when its storage allocation is not. The application requests bytes in file order, while the file system translates those requests into locations on the volume. However, a raw content scanner may have to infer the locations without the benefit of that translation. This distinction becomes important when the file’s signature remains recognizable but later clusters are no longer adjacent.

In this fragmented file recovery test, we change two conditions: the locations of the second and third data clusters and the reader’s knowledge of their order. By contrast, file deletion, NTFS record damage, and overwriting create additional problems because they affect whether clusters or their mapping remain available.

Fragmented File Recovery Test Setup and File Layout

The fragmented file recovery test uses a 60 × 60-pixel RGB PNG containing 10,928 bytes. Its contents stay identical across all three scenarios. Because each cluster holds 4,096 位元組, the PNG spans three clusters. Consequently, the third cluster contains 1,360 bytes of allocation space beyond the logical end of the file. Cluster numbers below use a volume-relative LCN address scheme; they are not physical sector addresses.

The layout uses NTFS-style virtual cluster numbers (VCNs) for file order and logical cluster numbers (LCNs) for locations on the volume. For the contiguous layout, VCNs 0, 1, and 2 map to LCNs 40, 41, 以及 42. By contrast, the fragmented layout maps them to LCNs 40, 73, 以及 106. Meanwhile, the other positions hold unrelated bytes. Throughout the fragmented file recovery test, the PNG content stays fixed. Only cluster placement and the reader’s available mapping change.

Data Run Comparison: One Extent vs Three

Inspect the mapping pairs in the nonresident $DATA attribute before looking at extracted file bytes. The first byte of each run identifies field sizes, the next value gives the run length in clusters, and the signed LCN delta locates its starting cluster. In this test, the contiguous layout has one Data Run; the fragmented layout has three. The last 00 terminates the runlist. These mapping-pair bytes are encoded from the experiment allocation; they were not extracted from a physical MFT record.

Compare the mapping, not just the extracted bytes.Same 10,928-byte PNG · different locations on the volume
NTFS NONRESIDENT $DATA · MAPPING PAIRS

S1 · Contiguous allocation

Single extent — no gaps between file clusters

4096 B / cluster
DATA RUN BYTES (hex)
11032800
Run header 11: 1-byte run length + 1-byte signed LCN delta; 00: end of runlist.
運行BytesVCNLCN長度
111 03 28VCN 0–2LCN 40–423
FILE-ORDER READ vs REAL LOCATION
File offsetVCNActual LCNRead LCN
0x0000VCN 04040   ✓
0x1000VCN 14141   ✓
0x2000VCN 24242   ✓

All three requested clusters follow the on-volume sequence. A sequential reader reproduces the file.

NTFS NONRESIDENT $DATA · MAPPING PAIRS

S2 · Fragmented allocation / wrong sequential read

Three extents — actual second and third clusters are elsewhere

4096 B / cluster
DATA RUN BYTES (hex)
11012811012111012100
Run header 11: 1-byte run length + 1-byte signed LCN delta; 00: end of runlist.
運行BytesVCNLCN長度
111 01 28VCN 0LCN 401
211 01 21VCN 1LCN 731
311 01 21VCN 2LCN 1061
FILE-ORDER READ vs REAL LOCATION
File offsetVCNActual LCNRead LCN
0x0000VCN 04040   ✓
0x1000VCN 17341   ✕
0x2000VCN 210642   ✕

A basic contiguous reader skips the actual VCN 1 and VCN 2 locations. The first wrong file byte occurs at 0x1000.

The encoding makes the difference explicit. In S1, 03 意指 three clusters 和 28 sets the starting LCN to 40. In S2, each run has length 01. Its signed LCN deltas are 28 (+40), 21 (+33), and 21 (+33), producing LCN starts 40, 73, and 106. Unlike file-offset Hex, these bytes describe the file’s allocation layout. For the NTFS encoding rule, see NTFS Data Runs documentation.

The test uses three scenarios:

  • Scenario1 — Contiguous baseline: Read the PNG sequentially from LCN 40 透過 42.
  • Scenario2 — Fragmented, mapping unavailable to the reader: Keep the file at LCNs 40, 73, 以及 106, but continue reading consecutive clusters beginning at LCN 40.
  • Scenario3 — Fragmented, mapping available: Read the fragmented clusters in the correct VCN order, then trim the result to the original logical file length.

Method: We placed the PNG bytes in a cluster-addressed test array and extracted them using the three read paths. We then checked each stream through full-byte comparison, SHA-256, and PNG chunk CRCs. We supplied the cluster map instead of extracting it from an NTFS MFT record. Therefore, these checks establish byte reconstruction outcomes, not physical-drive or recovery-software performance.

實驗程序

This fragmented file recovery test uses the same original bytes in every scenario. The five steps below isolate layout and mapping from file-content changes.

  1. Establish the source. Create the PNG, record its length and SHA-256 digest, and verify its signature, chunk structure, and chunk CRC values.
  2. Build S1. Place successive 4,096-byte portions of the file into LCNs 40, 41, 以及 42. Read forward from the PNG signature and validate the reconstructed stream.
  3. Build S2. Place the same portions at LCNs 40, 73, 以及 106. Leave the intervening positions filled with unrelated bytes. Apply the same forward, consecutive-cluster read beginning at LCN 40, without supplying the reader a cluster map.
  4. Build S3. Keep the fragmented storage layout unchanged, but supply the ordered VCN-to-LCN mapping. Next, reassemble the three portions and remove padding beyond the original file length.
  5. Compare outcomes. First, inspect the cluster boundaries at file-relative offsets 0x1000 和 0x2000. Then validate PNG chunk CRCs and compare the full reconstructed stream with the source digest.

For direct comparison, S2 reads exactly 10,928 bytes, matching the source file length. A signature-based carver would not automatically know that length; it would need to determine the file boundary from PNG structure, available metadata, or other evidence. Even so, the consecutive read already fails PNG validation, independently of how the reader determines file length.

Fragmented File Recovery Test Results

S1: Contiguous File Recovery Success

S1 starts with the nonresident $DATA 演出清單 11 03 28 00. It describes one extent containing three clusters starting at LCN 40. Therefore VCN 0, 1, and 2 resolve to LCN 40, 41, and 42. The simple consecutive reader follows exactly those locations, so its 10,928-byte output matches the source SHA-256 and passes PNG chunk CRC checks.

fragmented-datarun-scenario1

Figure 1. Contiguous file: a single Data Run maps VCN 0–2 to LCN 40–42.

A correctly identified file signature is useful here because the following data happens to remain sequential. In other words, sequential allocation explains this instance of contiguous file recovery success. A signature by itself does not establish complete recovery; the content must still satisfy the relevant format and integrity checks.

S2: File Carving Fragmented Files Experiment

In S2, the file contents do not change, but the nonresident $DATA runlist becomes 11 01 28 11 01 21 11 01 21 00. Decoding it reveals three separate one-cluster extents: VCN 0 → LCN 40, VCN 1 → LCN 73, and VCN 2 → LCN 106. A basic signature-based reader that ignores those extents instead assumes the next clusters are LCN 41 and 42. That incorrect assumption, not fragmentation itself, causes the candidate file to contain unrelated bytes from file offset 0x1000.

fragmented-datarun-scenario2

Figure 2. Fragmented file: three Data Runs map VCN 0, 1, and 2 to LCN 40, 73, and 106.

fragmented-scenario2

Figure 3. S2 Hex evidence at file offset 0x1000: the sequential read enters unrelated LCN 41 instead of LCN 73.

The Hex comparison therefore shows identical bytes before 0x1000 and a clear mismatch at the boundary. Thus, S2 has a correct 4,096-byte prefix followed by unrelated data. As a result, the PNG parser reports an IDAT CRC mismatch. In addition, the candidate stream has a different SHA-256 digest from the source. The incorrect data placement—not a change in the original image—is enough to explain the failure.

S3: Reconstructing a Fragmented File With Its Cluster Map

S3 uses the same fragmented runlist and the same cluster contents as S2. It does not defragment the file or rewrite a Data Run. Instead, the reconstruction reads LCN 40 → 73 → 106 in VCN order and trims the allocation padding to the original 10,928-byte file length. The resulting output matches the source SHA-256, and its PNG chunk CRCs pass. This is metadata-guided reconstruction, not signature-only file carving.

fragmented-scenario3-reconstructed

Figure 4. S3 reconstructed Hex at 0x1000: correct VCN-to-LCN reading restores the original bytes. Compare with Figure 3.

The reconstructed stream matches the source at both inspected cluster boundaries. Its SHA-256 matches the original digest, and all PNG chunk CRCs pass. These checks establish exact byte reconstruction when the correct mapping and every required cluster are available. However, an actual recovery case must first establish whether deletion, formatting, or file-system damage has destroyed the mapping or file bytes.

What the Byte Comparison Proves

The fragmented file recovery test produces exact 10,928-byte matches in S1 and S3, but not in S2. The first mismatch occurs at file offset 0x1000, exactly where the sequential read advances to the wrong cluster. The byte and CRC checks establish the central finding: a contiguous-read assumption works only when the file’s allocation follows that same sequence.

The Data Runs establish the allocation difference, while Figures 3 and 4 show the consequence at file offset 0x1000. Figure 3 shows unrelated data from LCN 41. Figure 4 shows the original bytes recovered by reading the actual second fragment at LCN 73. File-offset Hex is a secondary integrity check; the Data Runs are the evidence of fragmentation.

Why Fragmented File Recovery Results Differ

Microsoft’s explanation of clusters and extents distinguishes file-relative VCNs from volume-relative LCNs. Consequently, a single file can occupy several extents without placing them at adjacent volume locations. That is why a file whose logical bytes are ordered can nevertheless be scattered across a volume.

For example, on NTFS the nonresident attribute record structure can store the VCN-to-LCN mapping. Readers looking for the underlying file-record mechanism can consult the NTFS 主檔案表 guide. For a fuller explanation of how surviving mappings affect recovery, see File System Metadata Recovery. Those resources explain how the file system maintains the mapping; this test demonstrates what happens when that order is preserved, ignored, or restored.

的 W3C PNG specification provides a separate way to examine content. For example, a PNG starts with an eight-byte signature and contains structured chunks, including IHDR, IDAT, 以及 IEND. In addition, every PNG chunk stores a CRC for its chunk type and data. Accordingly, a recognizable PNG header does not mean all subsequent image data are valid. In S2, the parser reaches incorrect bytes while checking IDAT, making the corruption detectable.

然而、, file carving fragmented files is not limited to one naive forward-read strategy. Advanced carvers can examine chunk lengths, CRC constraints, compression properties, and candidate fragment relationships to infer missing boundaries. For example, a DFRWS study of syntactical PNG carving explores approaches that may recover fragmented PNG files without the original cluster map. The S2 result therefore describes the defined baseline method, not every existing or future carver.

Fragmented File Recovery: Practical Interpretation and Limits

The main lesson from this fragmented file recovery test is the difference between surviving file bytes 和 surviving knowledge of their order. All three PNG portions are present in S2, yet simple sequential reading cannot assemble them. In S3, the same portions form a valid file once the correct mapping guides the read. Therefore, neither a recognizable header nor a plausible filename proves that a recovered file contains all required content.

In a damaged or deleted-file case, the original mapping might no longer exist. For instance, later writes may overwrite an NTFS nonresident mapping or reuse its owning record. Likewise, a deleted FAT32 file may no longer retain its original FAT chain. An exFAT file can use contiguous allocation or a FAT chain, depending on its stream flags. For the relationship between metadata, allocation, and lost file links, see Orphaned Files and Lost Cluster Chains.

Moreover, reassembly is different from restoring bytes that no longer exist. Even with a correct mapping, recovery cannot reconstruct overwritten bytes. Similarly, a mapping cannot recreate old SSD content that the device no longer exposes after a discard operation. Although fragment-aware carving may help when the map is missing, it cannot guarantee correct ordering for every file format or storage condition.

For an actual recovery investigation, prevent further writes to the source and analyze a verified copy whenever possible. Then check allocation evidence and reconstructed content separately. Even so, a file that opens in an application may still be incomplete. A checksum match against a trusted original provides stronger evidence of exact reconstruction. By contrast, a digest calculated only after recovery identifies the output but cannot independently prove correctness.

總結

這個 fragmented file recovery test shows why storage order matters, even when every fragment remains available. The contiguous read in S1 reproduces the original PNG, and the mapped fragmented read in S3 does the same. In S2, consecutive reading fails as soon as it crosses into an unrelated cluster. The first differing offset, failed PNG CRC, and SHA-256 comparisons make the distinction clear.

The Data Runs explain the allocation difference directly: S1 encodes one three-cluster extent, while S2 and S3 encode the same three one-cluster extents. What changes between S2 and S3 is whether the reader uses that mapping.

However, the broader lesson is not that fragmentation makes recovery impossible. It is that file carving, cluster mapping, and file-format validation answer different questions. Therefore, a reader must identify the correct fragments, place them in order, and verify the reconstructed content before claiming complete recovery. Ultimately, success on a real device depends on what evidence survives.

Fragmented File Recovery Test FAQs

為什麼連續檔案的碎片還原通常比較容易?

連續檔案會將連續的邏輯位元組儲存於相鄰的儲存位置。一旦資料提取工具找到有效的起始簽名,通常便能依序檢視後續的資料。即便如此,仍須檢查該格式的內部結構;僅憑簽名本身並不能保證能獲得完整的結果。.

對於碎片化的檔案,檔案還原是否總是會失敗?

不。如 S2 所示,假設連續區塊存在的簡單還原方法,當後續片段位於其他位置時,可能會失敗。進階的「格式感知」還原技術有時能透過結構、CRC、壓縮資訊或其他驗證方法,識別碎片點並測試候選區段。最終,成功與否取決於檔案格式及可用的位元組數量。.

NTFS 元資料如何協助恢復已碎片化的檔案?

一名尚在世的非居民 $DATA 此屬性可提供 VCN 至 LCN 的對應資訊,用以識別檔案的延伸區塊。在進行碎片化檔案復原測試時,該對應關係會說明讀取器必須拼接哪些簇。若對應關係仍然有效,且所引用的簇仍可讀取,則復原程序即可將這些簇依原始順序進行拼接。 過期的映射無法還原已被覆寫的內容。.

正確的檔案標頭能否證明還原成功?

不。在 S2 中,開頭的 PNG 簽名以及前 4,096 位元組與原始檔相符。因此,後續的位元組有誤,導致 PNG 區塊的 CRC 校驗失敗。要完全還原檔案,需要更多證據,例如有效的內部結構、正確的內容,以及理想情況下與可信的原始摘要進行比對。.

僅知曉原始檔案的大小,是否足以重建碎片?

通常並非如此。檔案大小雖可決定邏輯資料的總量,但無法識別後續簇的位置或其順序。S2 雖刻意採用已知的來源長度進行比對,但此資訊並無法修正錯誤的順序讀取。因此,仍需其他映射或格式特有的線索。.

SHA-256 比對結果相符,是否能保證能復原一個未知檔案?

A SHA-256 match against a trusted digest of the original file is very strong evidence that the two byte streams are identical. If the original digest is unavailable, calculating a hash of recovered content does not reveal whether it matches the lost version. In contrast, format validation provides additional evidence of a different kind.

What does the CRC mismatch tell us about the recovered file?

In S2, the PNG header and first cluster remain intact, but a sequential read substitutes unrelated bytes beginning at 0x1000. .......。 IDAT chunk CRC no longer matches its stored value. That mismatch identifies corrupted chunk contents, although a valid CRC by itself would not prove that every aspect of a recovered image is correct.

Vasilii 是一位在該領域擁有約 10 年實務經驗的資料復原專家。在他的職業生涯中,他已成功解決數千個複雜的個案,包括刪除的檔案、格式化的硬碟機、遺失的磁碟分割和 RAW 檔案系統。他的專業知識涵蓋使用十六進位編輯器等專業工具的手動復原方法,以及使用復原軟體的進階自動解決方案。Vasilii 的使命是讓 IT 專業人士和一般使用者都能獲得可靠的資料復原知識,協助他們保護寶貴的數位資產。.