File Carving: How Data Recovery Works

file-carving-how-data-recovery-works

File carving finds and extracts files by reading their data instead of using file-system records. It looks for known byte patterns, checks the file layout, and finds likely start and end points. This can help when folder or file records are gone. However, it may not bring back old file names or rebuild fragmented files.

The method works on data that a tool can still read. It can apply to NTFS, FAT32, and exFAT drives, as well as HDDs, USB drives, SD cards, SSDs, and disk images.

Table of Contents

How File Carving Works

A typical file carving scan has four steps:

  1. Search readable data for known file signatures.
  2. Check each match and read its file layout.
  3. Find the likely start and end of the file.
  4. Copy the data and test the result.

Some tools scan free space. Others scan a full volume or a disk image. The scan area depends on the tool and the task.

Find File Headers and Signatures

A file signature is a set of bytes that can point to a file type. A recovery tool looks for these patterns to find possible files.

For example, a PNG file starts with this eight-byte signature: 89 50 4E 47 0D 0A 1A 0A.

A match points to a possible PNG file. It does not prove that the full image is still there. Some bytes may be gone, damaged, or mixed with data from other files. Signature-based file recovery starts with this search, while deeper methods also check the file layout.

A file name or extension does not give the same proof. Renaming a .jpg file to .png does not change its data. Headers may also hold fields for size, image width, or other file details. See the file signatures and magic numbers guide for more examples.

Find the Start and End of a File

Finding a header is only the first step. A tool must also decide how many bytes belong to that file.

File types mark their end in different ways:

  • Some have a known end marker.
  • Some store a file or data size.
  • Some split data into chunks or records.
  • Others need a parser to read the file layout.

So, a search for a header and footer will not work for every file. An end marker may also appear inside normal data. Some file types have no single end marker.

PNG Chunks: Why the First IEND Match Can Be Wrong

The W3C PNG spec says that a PNG file starts with an eight-byte signature. PNG stores the rest of the file in chunks.

Each chunk has four fields:

Field

Length

Purpose

Length

4 bytes

Gives the size of the data field

Type

4 bytes

Names the chunk

Data

Variable

Holds the chunk data

CRC

4 bytes

Checks the type and data

A full chunk uses 12 + Data Length bytes. The Length field does not count itself, the Type field, or the CRC.

Every PNG starts with an IHDR chunk. Its data field is always 13 bytes. The full chunk is 25 bytes long.

Its signature uses offsets 0x00–0x07. The first chunk starts at 0x08. The next chunk starts at 0x21:

0x08 + 25 = 0x21

This math shows where the next chunk starts.

Consider a specification-based teaching sample: a valid 136-byte PNG. Its tEXt chunk holds the text IEND as part of a comment.

Structure

Chunk start

Data length

Next offset

PNG Signature

0x00

8 bytes

0x08

IHDR

0x08

13 bytes

0x21

tEXt

0x21

56 bytes

0x65

IDAT

0x65

11 bytes

0x7C

IEND

0x7C

0 bytes

0x88

png-hex-editor-iend-analysis

The tEXt data starts at 0x29. The first text match for IEND is at 0x31. It sits inside the text data. It is not the end of the PNG.

The real IEND chunk starts at 0x7C. Its Type field starts at 0x80. Its Data field has no bytes, so the PNG ends at 0x88.

This sample shows why a byte search is not enough. A byte search finds the first match. A PNG parser reads each Length field and checks if IEND sits in a chunk Type field.

PNG also has a CRC for each chunk. The CRC checks the Type and Data fields, not the Length field. It can find some forms of damage. However, it cannot prove that a found image is the same as the old one.

Copy and Check the Found File

After a tool finds the likely end, it copies the data. But a copied file is not always a good file.

It may have a valid header but lack later data. It may also have wrong size fields, broken records, or bytes from other files.

A tool can check the result in several ways:

  • Check that key headers and fields are present.
  • Check size values and file bounds.
  • Check CRCs or other checks when the file type has them.
  • Open or parse the found file.
  • Compare its hash with a trusted copy, if one exists.

A file that opens may still be broken. Some apps can show part of a damaged image or document.

File Carving Techniques

Different file carving techniques use different levels of file detail. A tool may use more than one method in the same scan.

Method

How It Works

Main Limit

Header and footer

Finds start and end patterns

A pattern may appear inside other data

Size-based

Uses a known size or a size field

The size may be lost or wrong

Layout-based

Reads fields, chunks, or records

Needs rules for that file type

Content checks

Tests if the data forms a valid file

Checks vary by file type

Fragment search

Looks for parts that may belong together

The right order may be hard to prove

Header, Footer, and Size

These methods work best when a file type has clear start and end data. A tool can find a header and look for its end marker. It can also read a size field and copy that many bytes.

But an end marker may sit inside file data. A size field may also refer to one part of a larger file. If a tool reads the wrong value, it may copy too much or too little.

Layout and Content Checks

A layout-based tool reads the parts inside a file. For example, it can read PNG chunk sizes or check records in a ZIP file.

Content checks go one step further. They test whether the parts form a file that makes sense. These checks can cut down on false matches. Still, they cannot bring back bytes that are gone.

A file may pass some checks and still differ from the old file. These checks raise trust in a result, but they do not prove that it is the same file.

Find File Fragments

Fragment search tries to put split file parts back in the right order. It may use file rules, data patterns, and other clues.

Research from DFRWS on carving split files with object checks looks at ways to check and join file parts.

This work is harder than a basic signature scan. The result depends on the file type, the parts that remain, and clues about their order.

File Carving vs. Metadata-Based Recovery

The key difference between file carving and metadata-based recovery is the data each method uses to find a file.

Comparison

Metadata-Based Recovery

File Carving

Main clue

File-system records and cluster maps

File signatures and data layout

Old file name

May still exist in file records

Usually not found from file data alone

Folder path

May still exist in folder records

Usually not kept

Fragmented files

Can use saved cluster maps

Needs more clues to join parts

Main need

Usable file records or maps

Readable data and known file rules

Best fit

File records still help find the data

File records are gone or cannot help

How File-System Records Find Data

On NTFS, the Master File Table holds records about files. A file record can have data that tells the system where file content sits.

For data stored outside the file record, NTFS mapping pairs list data runs. They can show which clusters hold each part and the order of those parts.

Microsoft explains these records in its Master File Table guide and attribute record header guide. These pages cover NTFS version 3.

Other file systems use other maps:

  • FAT32 uses FAT entries to link the clusters that hold a file.
  • exFAT uses directory entries to describe file data. Its NoFatChain flag shows whether a file uses one run of clusters or a FAT chain.

The Microsoft exFAT spec sets out these rules. If these maps still work, a tool can use them to find split parts in the right order. This gives metadata-based recovery an edge over a scan that only looks for file signatures.

But good file records do not prove that the data is still whole. The NTFS Deleted File MFT Test shows why file records, data location, and file content need their own checks. For more on this method, see file system metadata recovery.

Raw Data Recovery Explained: Why File Names Go Missing

Raw recovery often means a scan that reads data without using the normal file and folder records. In many cases, it includes a scan for file signatures and file carving.

The term can mean different things in different tools. It is not a file-system standard. In this context, raw file carving recovery means finding files in readable data without using the old folder records.

Raw Recovery Without Original File Names

File systems keep file names and folder paths in their own records. Those names do not have to appear in the file data.

So, a tool may find a JPEG or PDF but not know its old name or folder. It may give the found file a new name instead.

PhotoRec says that it does not bring back old file names or folder paths. It finds files by their data signatures. See the PhotoRec guide.

Some details may still stay inside the file. A JPEG may hold EXIF data. A PDF may hold a title or author name. These details are not the same as the old file name or folder path.

Raw Recovery Is Not a RAW File System

The word RAW can mean two things:

  • Raw recovery: A scan that reads data without using normal file and folder records.
  • RAW file system: A volume that Windows cannot read as a known file system.

A RAW volume does not prove that all data is gone. The file-system records may be damaged, hard to read, or from a file system that Windows does not support.

A raw scan may still find data that can be read. But it does not fix the volume or bring back its old folder tree.

Encryption also matters. A BitLocker volume usually needs to be unlocked before a tool can read the files inside it. PhotoRec explains this need for BitLocker volumes.

Why File Fragmentation Limits File Carving

A file is split when its data sits in more than one run of clusters. A file-system-aware tool can use saved cluster maps to find each part. A basic carver may not have those maps.

Think of a file with three parts:

A → B → C

If the parts sit next to each other, the data order may also be A → B → C. A tool can read from A to C if it knows the right start and end.

Now look at a split file:

Storage order

Data

Block 1

A

Block 2

X (data from another file)

Block 3

B

Block 4

C

Logical file order Required sequence
A B C
Readable storage sequence Illustrative block order
A B C
Sequential read from the first block A → B → C

The file occupies consecutive blocks. A sequential read can collect A, B, and C in order if the start and boundary are known.

Illustrative model only. A, B, and C are parts of one file; X belongs to unrelated data. The blocks do not represent physical NAND pages or a real disk image.

The file still needs A → B → C. But a scan from A may read A → X → B. It has mixed in data from another file.

So, a good header does not prove that the next blocks belong to the same file. The NIST file carving draft lists split data as a key issue for file carving.

Can File Carving Recover Fragmented Files?

Sometimes. If file-system maps still work, a tool may use them to find each part. Advanced carving can also use file rules and other clues.

But there may be many possible parts. The right order may not be clear. Compressed or locked data can make the job even harder because it hides clues in the data.

No one method can promise to rebuild every split file from its data alone. See Fragmented Files Explained for more on split files.

File Carving Limitations and Recovery Conditions

The result depends on how much data a tool can still read and how well it can find the file parts.

Limit

Why It Matters

Possible Result

Overwritten data

New data takes the place of old bytes

Some or all data may be lost

SSD TRIM

The drive may stop showing freed data

Old data may no longer be read

Split files

Parts do not sit in a row

The file may be incomplete

No clear end

The file has no safe end point

The tool may copy too much or too little

False matches

The same byte pattern may appear in other data

A false file may be found

Encryption

The tool cannot read locked data

File signatures may not show

Unknown file type

The tool has no rules for that type

The tool may miss the file

Overwritten Data

A tool can only copy bytes that it can still read. It cannot make old data from new data. Some parts may survive a partial write. Even then, the found file may be broken or lack key data.

SSD TRIM and Data That Cannot Be Read

On some systems, Windows can send TRIM or deallocation hints when file-system space is freed. These hints tell the drive that it can reuse those blocks. Microsoft explains this in its guide to TRIM and Unmap hints.

TRIM does not mean that every deleted file vanishes at once. The result depends on the drive and its setup. But once the drive has dealt with freed blocks, normal reads may no longer return the old data.

So, a scan cannot copy data that the drive no longer shows.

Locked Data and Unknown File Types

Locked data often hides the byte patterns that a tool needs to find a file. The tool may need the data to be unlocked first.

A tool may also find a file start but fail to read the rest. This can happen if it does not know that file type or a newer version of it.

So, no result does not always mean that no data remains. The tool may not know how to read what is there.

How to Check Carved Files

A match does not mean that a tool has found a full file. Check each result in steps.

Check

What It Shows

What It Does Not Show

Signature found

A known byte pattern is there

A full file is there

File layout looks right

Some file rules match

All old data is still there

File opens

An app can read some or all of it

It is the same as the old file

Hash matches an old copy

Both files have the same bytes

The old name or folder

Some file types use CRC checks. These can find some data errors. But a good CRC does not prove that a file is the real old file.

If you have a trusted copy, compare file hashes. A match shows that both files have the same bytes. If you do not have a copy, check the file layout, size, content, and whether an app can read it from start to end.

When Should You Use File Carving?

Carving can help when file-system records no longer show where files are, but a tool can still read some file data.

Common cases include:

  • A damaged file system with missing folder records.
  • Deleted files whose file records no longer help.
  • A formatted drive that still holds old data.
  • A disk image that needs a scan for file types.
  • Files that a metadata-based scan cannot find.

If file records still work, metadata-based recovery may be a better first choice. It can keep old names, folder paths, and maps for split files.

Before you try to recover data, protect the source drive:

  1. Stop saving new data to the drive.
  2. Do not format, set up, or repair the source before you save key data.
  3. If the data matters, make a full drive image before more scans.
  4. Scan the image or use a read-only source when you can.
  5. Save found files to a different drive.

If the drive clicks, drops out, or shows major read errors, stop repeated scans. More reads may make a failing drive worse.

File recovery, file-system repair, and hardware repair are not the same job. Carving copies data that still exists. It does not fix a bad drive or rebuild a file system.

Conclusion

File carving finds and copies files by reading their data and file layout. It does not need the old file-system records. Its success depends on known file patterns, clear start and end points, readable data, and clues that show the right order of file parts.

A signature match is only the first step. File checks and tests help show if the result is whole and useful. If file-system records still work, they may hold details that a data scan cannot bring back, such as old names, folder paths, and maps for split files.

FAQ

What is file carving in data recovery?

File carving finds and copies possible files by looking for known byte patterns and file layouts. It can help when file-system records are gone or damaged, as long as the data that the file needs can still be read.

Can file carving recover old file names?

Usually not. File systems keep file names and folder paths in their own records. A carving tool may copy the file data and give it a new name. Some file details may still stay inside the file.

Can file carving recover fragmented files?

Sometimes. A tool may use file-system maps or file rules to put fragmented parts back in order. But a basic scan may mix data from other files into the result. The chance depends on which parts remain and what clues the tool can use.

Is raw recovery the same as a RAW file system?

No. Raw recovery is a way to scan data without normal file records. A RAW file system is a volume that Windows cannot read as a known file system. The two terms do not mean the same thing.

Does file carving work after a drive is formatted?

It may work if the drive still exposes the old data and has not overwritten it or made it hard to read. Results depend on the format, the file type, split data, and the kind of drive.

Can file carving recover data that has been overwritten?

No. A tool cannot bring back bytes that new data has replaced. Some parts may still remain after a partial write, but the file may not be whole or usable.

Does SSD TRIM stop file carving?

TRIM can stop a tool from reading old data after the drive processes freed blocks. The result depends on the drive, setup, and timing. Not every deleted SSD file is lost at once.

Is metadata-based recovery better than file carving?

Not in every case. Metadata-based recovery can keep names, folders, and maps for split files when records survive. Carving can help when those records are gone but file data can still be read.

Vasilii is a data recovery specialist with around 10 years of hands-on experience in the field. Throughout his career, he has successfully solved thousands of complex cases involving deleted files, formatted drives, lost partitions, and RAW file systems. His expertise covers both manual recovery methods using professional tools like hex editors and advanced automated solutions with recovery software. Vasilii's mission is to make reliable data recovery knowledge accessible to both IT professionals and everyday users, helping them safeguard their valuable digital assets.