Skip to content
Tutorials Center
My learning

Topics

Lesson 13 of 36 ยท Disk and File System Forensics

Deleted Files and Slack Space

Understand what really happens when a file is deleted, how examiners recover it from FAT and NTFS, what file slack, unallocated space and wiping mean, and why SSDs and TRIM change the rules.

Pressing Delete does not erase data. For speed, file systems only change a few small records to say that the space is available again, and they leave the contents alone until something else overwrites them. This is the reason forensics can recover "deleted" files, and also the reason that a quick format or an empty recycle bin is not a secure erase. This lesson explains the different places where remnants live and when they survive.

What deletion does

Two steps usually happen, and they differ between file systems.

File system On delete Often still recoverable
FAT First byte of the directory entry becomes 0xE5; FAT chain entries set to 0 Name (minus first letter), size, first cluster, content until reused
NTFS MFT record flagged "not in use"; clusters marked free in $Bitmap Whole MFT record: name, timestamps, data runs, content until reused; small files sit inside the record
ext4 Inode marked free; extents and size may be zeroed Directory entry name sometimes; journal may hold older inode copies
Recycle Bin / Trash File is moved to a hidden folder with a metadata record Complete file, original path and deletion time

Deleting through the graphical interface usually moves a file into the Recycle Bin on Windows ($Recycle.Bin, with $I files holding the original path and deletion time and $R files holding the content). Only emptying the bin (or using Shift+Delete) performs the file-system deletion described above.

Recovering from FAT: a simulation

In FAT, the directory entry survives with its first character replaced. If the clusters were contiguous and not reused, you recover the file by reading size bytes from the first cluster. The next program makes a tiny volume, deletes a file the way FAT does, and recovers it.

Python Delete and recover a file on a simulated FAT volume

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

This only works because we assumed the clusters were contiguous. If the file had been fragmented, the FAT chain, now zeroed, would be the only record of where the other pieces lived, and you would need carving or journal data.

Overwriting

Recovery depends on the clusters not being reused. Heavily used disks overwrite deleted data quickly; a lightly used external drive can keep it for years. Even after partial overwriting you may recover the unreplaced portion. Modern analysis tools show deleted files with a clear marker and tell you whether the clusters are "overwritten" (now allocated to another file), and you should verify that by comparing hashes or reading the content.

Slack space

Files are stored in whole clusters, so the last cluster is rarely filled. The leftover bytes are slack space:

  • RAM slack: the remainder of the final sector of the file. Old operating systems padded it with whatever was in memory, so it could contain unrelated fragments (passwords, text).
  • Drive slack (file slack): the remaining whole sectors of the final cluster, which keep whatever the clusters held before.
flowchart LR
    A["Cluster 1<br/>full of file data"] --> B["Cluster 2<br/>file data ends here"]
    B --> C["RAM slack<br/>(rest of last sector)"]
    C --> D["Drive slack<br/>(rest of cluster:<br/>old data may remain)"]

Suppose a 4 KiB cluster once held an old document and now holds a short note. The note covers the first 300 bytes; the rest of the cluster still contains the old document's text. That leftover is evidence of what used to be there.

Python Find old data hiding in file slack

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Examiners search slack space (and unallocated space) with keyword and pattern searches. Because a file's slack is part of the allocated cluster, a deleted old file can survive "behind" a newer file.

Unallocated space

Unallocated space is every cluster the file system currently marks as free. It contains deleted file contents, remains of older file systems and carved material. Tools can extract unallocated space as a single file so you can run searches and carving on it. Compare with file system metadata remains: orphaned MFT records and inodes that no longer have a parent directory (they appear as "orphan files" in Autopsy).

Secure erasure and wiping

Overwriting file data with zeros or random bytes removes it. Tools that do this include shred, sdelete, cipher /w, and dd if=/dev/zero. Signs of wiping:

  • Large regions of identical bytes (all zeros, all 0xFF) where files should have been.
  • Wiping tool artifacts: prefetch entries, program installs, shell history, registry traces.
  • File names that were changed to repeating characters before deletion (some tools rename files first).

Wiping does not erase the evidence that wiping occurred.

Python Detect wiped regions

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A uniform block alone proves nothing: new, unused space is zeros too. Context decides.

SSDs, TRIM and flash storage

Solid-state drives behave differently. When a file is deleted, the operating system may send a TRIM command telling the drive the blocks are unused. The drive controller can then erase them in the background (garbage collection), sometimes within minutes, even on a powered, write-blocked drive. Consequences:

  • Deleted file recovery on SSDs is often much less successful than on spinning disks.
  • Imaging an SSD can show contents changing between two reads of the same sector.
  • Wear levelling moves data around internally, so overwriting a file may leave old copies in blocks the operating system cannot see.
  • Phones and USB sticks use similar flash controllers, with similar effects.

Because of this, acquiring flash media quickly, and documenting the observed behaviour, matters.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What happens to a FAT directory entry when a file is deleted?

    FAT marks the entry deleted with 0xE5 and keeps the rest, so name, size and first cluster can be read.
  2. 2. What is drive slack?

    Drive slack is the part of the final cluster after the last sector holding file data; it may contain older data.
  3. 3. Why is recovering deleted files from an SSD often harder?

    After TRIM, the drive may clear freed blocks on its own.
  4. 4. Large regions of 0x00 where files should be could indicate what?

    Uniform blocks are a clue only; corroborate with wiping-tool artifacts.

Summary

  • Deleting changes metadata and allocation but usually leaves the content until it is overwritten.
  • FAT keeps most of the directory entry; NTFS keeps the MFT record; the Recycle Bin keeps the whole file plus path and time.
  • Slack space (RAM slack and drive slack) and unallocated space can hold remains of older files.
  • Wiping leaves uniform blocks and tool artifacts; SSD TRIM can erase deleted data without user action.
  • Report the state of recovered files honestly: complete, partial or overwritten.

Next: NTFS timestamps and metadata