Contig - Sysinternals | Microsoft Learn

Contig v1.83 — Summary

Author: Mark Russinovich Published: March 9, 2023

What it is

  • Contig is a single-file defragmenter for Windows that makes individual files contiguous on disk. It’s intended for quickly optimizing frequently used or repeatedly fragmented files rather than performing full-disk defragmentation.

Why use it

  • Useful when specific files remain fragmented despite running full-disk defragmenters.

  • Good for files that continuously become fragmented or that you want kept in as few fragments as possible.

Key usage

  • Command syntax:

    Contig.exe [-a] [-s] [-q] [-v] [existing file]
    Contig.exe [-f] [-q] [-v] [drive:]
    Contig.exe [-v] [-l] -n [new file] [new file length]
  • Parameters:

    • -a : Analyze fragmentation

    • -f : Analyze free space fragmentation

    • -l : Set valid data length for quick file creation (admin required)

    • -q : Quiet mode

    • -s : Recurse subdirectories

    • -v : Verbose

Supported NTFS metadata

  • Contig can analyze and defragment NTFS metadata files such as $Mft, $LogFile, $Volume, $AttrDef, $Bitmap, $Boot, $BadClus, $Secure, $UpCase, and $Extend.

How it works

  • Uses native Windows NT defragmentation APIs (introduced with NT 4.0).

  • Scans disk to map free areas, locates the target file, decides if optimization is feasible based on free space and current fragmentation, and moves the file into suitable free areas when possible.

System requirements

  • Client: Windows 8.1 and higher

  • Server: Windows Server 2012 and higher

  • Nano Server: 2016 and higher

References and downloads

  • Download Contig (366 KB): https://download.sysinternals.com/files/Contig.zip

  • More background references cited in the article: Helen Custer’s Inside Windows NT and Mark’s 1997 Windows NT Magazine column “Inside the Object Manager.”

Last updated: 03/09/2023