Windows 2000 Native NTFS File Compression
Microsoft Windows 2000 provides native, transparent file and folder compression on partitions formatted with the NTFS file system. This article explains how the operating system implements this feature at the file-system level, covering the underlying compression algorithm, cluster-allocation mechanics, administrative control via system utilities, and inherent operational constraints.
The Underlying Algorithm and Compression Units
Windows 2000 utilizes a variation of the Lempel-Ziv (LZ77)
dictionary-based algorithm for real-time data compression. Rather than
compressing an entire file as a single contiguous stream, the NTFS
driver (Ntfs.sys) divides the file data into fixed-size
segments called Compression Units (CUs).
A Compression Unit is always 16 clusters in size. When a file is written to disk, NTFS analyzes each 16-cluster unit individually:
- If compressing the 16 clusters reduces the required space by at least one full cluster (to 15 clusters or fewer), the compressed data is written to disk. The remaining, unused clusters in that unit are freed and left unallocated as sparse space.
- If compressing the unit does not save at least one cluster, NTFS leaves that specific 16-cluster block uncompressed.
Because compression occurs in discrete 16-cluster blocks, random read and write access remains relatively fast; the system only needs to decompress the specific unit containing the requested data rather than the entire file.
Cluster Size Limitation
Native NTFS compression in Windows 2000 functions only on volumes formatted with a cluster size of 4 kilobytes (KB) or smaller. If an NTFS volume is formatted with an allocation unit size larger than 4,096 bytes (such as 8 KB, 16 KB, or 64 KB), the compression attribute is completely disabled by the file system. This restriction exists because managing 16-cluster compression units with larger cluster sizes imposes severe memory and performance overhead on the operating system.
Transparency and Performance Characteristics
Compression is fully transparent to user-mode applications. When an application requests read access to a compressed file, the NTFS driver intercepts the request, reads the compressed blocks from the physical disk, decompresses the data into system memory, and passes the uncompressed stream to the application. When saving, the reverse occurs.
This mechanism introduces distinct performance trade-offs:
- CPU Overhead: Compression and decompression consume additional CPU cycles during input/output operations.
- Disk I/O: Physical read and write operations are reduced because less physical data moves between the storage controller and system memory, which can occasionally benefit systems with slow disk subsystems.
- Fragmentation: Because files expand and contract dynamically within sparse allocation boundaries, heavily modified compressed files tend to fragment significantly faster than uncompressed files.
Inheritance and Management
NTFS marks compressed items using an internal file attribute
(FILE_ATTRIBUTE_COMPRESSED). Compression can be applied
granularly to individual files, entire directories, or whole
volumes.
When applied to a folder, the folder itself is not compressed; instead, it serves as a template. Any new file created inside or copied into that folder automatically inherits the compressed attribute.
Administrators and users manage native compression through two primary interfaces in Windows 2000:
- Windows Explorer: Users can select file or folder properties, navigate to the General tab, click "Advanced," and check the box labeled "Compress contents to save disk space." Windows 2000 also introduces an option to display the names of compressed files and folders in an alternate color (blue by default) for visual identification.
- The Command Line (
compact.exe): Administrators can batch-process files and automate compression through scripts using thecompactutility, which supports switches for recursive directory compression, forcing compression on corrupt files, and viewing current compression ratios.
Limitations and Incompatibilities
Windows 2000 does not permit a file to be both compressed and
encrypted at the same time. The native NTFS Encrypting File System (EFS)
and native NTFS compression are mutually exclusive attributes; setting
one automatically clears or prohibits the other. Additionally,
system-critical files, such as the Windows boot loader
(NTLDR) and active paging files
(pagefile.sys), cannot be compressed.