Storage & Data Recovery ADVANCED Linux (Primary) ⏱️ 6 min read πŸ“… Updated: 13 Sep 2026

Forensically Carving Deleted Files from Unallocated NTFS Space in Linux

This advanced guide details the forensic process of recovering deleted files by carving data signatures directly from unallocated sectors on an NTFS volume using specialized Linux tools like foremost or scalpel.

Gurveer Singh
Gurveer Singh βœ“ Verified Specialist
Founder & Chief Architect Β· hSECURITIES Labs
⚑ FAST-TRACK PROTOCOL

Direct Diagnostic & Remediation Summary

  • Prerequisite Check: Ensure you have a write-blocker attached and mounted read-only. Use sudo mount -o ro,remount /dev/sdXN /mnt/evidence.
  • Run Carving Tool: Execute the chosen tool against the raw image of the unallocated space. Example using foremost: foremost -t all -i /path/to/disk_image.dd -o ./recovered_data.
πŸ› οΈ Tools & Prerequisites: 1. Forensic Workstation running a Linux distribution (e.g., Kali Linux, Ubuntu). 2. A hardware write-blocker connected to the source drive (HDD/SSD) containing the NTFS volume. 3. Root or elevated administrative privileges (<code>sudo</code>). 4. Necessary tools installed: <strong>foremost</strong> or <strong>scalpel</strong>.
Executive Overview

Forensic Data Carving from Unallocated Space

Data carving is the process of recovering files based on known file headers and footers (signatures), ignoring the file system's metadata (like MFT entries) which tracks allocated space. This technique bypasses standard OS deletion mechanisms to recover remnants of deleted data structures directly from raw disk blocks.

This guide assumes you have already created a forensic image (a bit-for-bit copy, e.g., using dd) of the target volume to ensure the original evidence remains untouched.

πŸ” Root Cause & Diagnostic Overview:The operating system's file system (NTFS) marks space as 'unallocated' when a file is deleted, but it does not overwrite the actual data blocks immediately. These blocks remain on the disk until new data overwrites them. Data carving tools operate at the physical sector level, scanning these unallocated sectors for recognizable byte sequencesβ€”the headers and footers of specific file types (e.g., JPEG starts with FF D8, PDF starts with %PDF-)β€”to reconstruct files that the OS metadata no longer points to.
STEP 1

Evidence Acquisition and Integrity Check

The absolute first step is creating a forensic image. NEVER work on the original media. Use dd to create an exact, bit-for-bit copy of the entire physical disk or partition.

  • Imaging the Source: Identify the source device (e.g., /dev/sdb) and output file path (/mnt/evidence/disk_image.dd).
  • Executing dd: Run the imaging command to capture all sectors, including slack space and unallocated clusters.
sudo dd if=/dev/sdX bs=1M conv=noerror,sync | tee /mnt/evidence/disk_image.dd

After imaging, calculate the cryptographic hash (SHA256) of both the original source partition and the resulting image file to prove data integrity.

sha256sum /dev/sdXN  # Original Hash
sha256sum /mnt/evidence/disk_image.dd # Image Hash
STEP 2

Identifying the Target Space for Carving

While foremost and scalpel can read entire disk images, it is often more efficient to target only the unallocated space. First, use a partition analysis tool like mmls (from The Sleuth Kit) or specialized write-blocker utilities to determine the precise start and end sectors of the unallocated region within the image file.

  • Mounting Read-Only: Ensure any mounting is read-only to prevent accidental writes.
  • Extracting Unallocated Data (Advanced): Some advanced workflows involve using dd again, but this time specifying the offset corresponding to the unallocated clusters identified in Step 2, resulting in a smaller, targeted input file for carving.
STEP 3

Executing Data Carving with Foremost or Scalpel

We will use foremost as the primary example, as it is robust for signature matching across various file types. You must specify the data type (or 'all') and the input image.

  • Installation Check: Ensure the tool is installed: sudo apt update && sudo apt install foremost
  • Running Foremost (All Types): This scans for common signatures across the entire image, outputting results into a structured directory.
foremost -t all -i /mnt/evidence/disk_image.dd -o ./recovered_data

Alternatively, scalpel offers more granular control over header definition via its configuration file (/etc/scalpel/sig_file).

sudo scalpel -o ./recovered_data /mnt/evidence/disk_image.dd
STEP 4

Post-Processing and Validation

The output directory (./recovered_data) will contain subdirectories named after the file types found (e.g., jpg, pdf). The files recovered are raw data blocks that need manual validation.

  • Reviewing File Names: Files will often have generic names (e.g., file0001.jpg) because the original filenames were part of the deleted metadata and are not carved with the data payload.
  • File Integrity Check: Open a sample file from each type in a standard viewer (e.g., viewing a recovered JPEG in an image editor) to confirm it renders correctly, indicating the carving was successful for that signature.
  • Handling Fragmentation: Be aware that if a single file spanned multiple non-contiguous unallocated clusters, basic carving tools might only recover the first segment. This requires advanced analysis or specialized commercial software.
TROUBLESHOOTING

Common Pitfalls & Advanced Diagnostics

If carving fails to yield expected results, consider these points:

  • Incorrect Write Blocking: If the write-blocker is bypassed or malfunctioning, any write operation invalidates the evidence. Always verify read-only status before imaging.
  • File Overwriting/Zeroing: The most common failure point: if the deleted space has been overwritten by subsequent writes (e.g., OS journaling, new file creation), the data is irrecoverable via carving.
  • Tool Limitation (Slack Space): Standard tools look for headers/footers. If a file was partially overwritten or spanned across system slack space that wasn't fully imaged, recovery will be partial or fail entirely.
FINAL STEP

Verification, Results & Long-Term Stability Validation

The validation process involves confirming that the recovered data is forensically sound and useful. A successful carve means the file structure signatures were correctly identified and extracted into a usable container.

  • Hashing Recovered Data: Hash the entire recovered_data directory contents to maintain a chain of custody record for the recovered evidence.
  • Documentation: Document every command, every tool version used, and the exact parameters passed. This documentation is critical for court admissibility.
  • Prevention Tip: For maximum data integrity on sensitive systems, implement regular differential backups to ensure that if a catastrophic failure occurs, you can restore from a known good state before forensic acquisition is necessary.
Resolution Complete: By following the imaging, carving, and validation steps, you have successfully extracted file remnants from unallocated space on an NTFS volume. If files are missing, it almost certainly indicates that the physical sectors containing the data were overwritten by new system activity since deletion.

FAQ

Q: Can I carve deleted files from a live, running Windows machine?

A: Absolutely not. You must always work on an offline image created using a hardware write-blocker. Working on a live system guarantees data modification and evidence contamination.

Q: What is the difference between carving and file system recovery?

A: File system recovery attempts to repair the metadata (like rebuilding MFT entries) to restore pointers. Data carving ignores the metadata entirely and reconstructs files purely based on byte signatures, making it effective even when the file system structure is severely damaged.

Q: Does this process work if the deleted data was encrypted?

A: No. If the original data stream was encrypted at rest (e.g., BitLocker), carving will only recover ciphertext blocks, which are useless without the associated decryption keys.

COMMAND LINE / TERMINAL
sudo dd if=/dev/sdX bs=1M conv=noerror,sync | tee /mnt/evidence/disk_image.dd
sha256sum /dev/sdXN
sha256sum /mnt/evidence/disk_image.dd
foremost -t all -i /mnt/evidence/disk_image.dd -o ./recovered_data
sudo scalpel -o ./recovered_data /mnt/evidence/disk_image.dd

Frequently Asked Questions

Can I carve deleted files from a live, running Windows machine?

Absolutely not. You must always work on an offline image created using a hardware write-blocker. Working on a live system guarantees data modification and evidence contamination.

What is the difference between carving and file system recovery?

File system recovery attempts to repair the metadata (like rebuilding MFT entries) to restore pointers. Data carving ignores the metadata entirely and reconstructs files purely based on byte signatures, making it effective even when the file system structure is severely damaged.

Does this process work if the deleted data was encrypted?

No. If the original data stream was encrypted at rest (e.g., BitLocker), carving will only recover ciphertext blocks, which are useless without the associated decryption keys.

Engineering Assistance

Need help implementing this solution?

Our cybersecurity and infrastructure engineers can audit, harden, or configure your systems directly.

Request Technical Assistance β†’
Gurveer Singh
Gurveer Singh βœ“ Verified Author
Founder & CEO at hSECURITIES | Cybersecurity Educator | Security Researcher | Ethical Hacking Enthusiast | Technology Mentor
Meet the Founder β†’

Gurveer Singh Saggu is the Founder and CEO of hSECURITIES, a cybersecurity and technology education platform focused on practical learning, digital security awareness, hardware diagnostics, Linux administration, and real-world cybersecurity training.

With a strong passion for technology, ethical hacking, and security education, he has spent years helping students, professionals, and organizations understand modern cyber threats and develop practical technical skills. Through hSECURITIES, he creates hands-on learning resources, technical guides, security awareness content, and community-driven initiatives that make cybersecurity more accessible.

His mission is to bridge the gap between theoretical knowledge and practical implementation by providing step-by-step learning experiences, technical troubleshooting resources, and security-focused educational platforms.

Community Discussion & Confirmations (0)

Technical questions, hardware findings, and verified fix reports.

No reader questions posted yet. Have you tried this solution or experienced an edge case? Post below.

Ask a Question or Share Solution