TExcelTAD
Home › Operating Systems: Linux & Windows › NTFS & Windows File Systems

NTFS & Windows File Systems

Windows has used NTFS (New Technology File System) for its system drive since Windows NT 3.1 in 1993, and every Windows 11 PC still boots from it. Around it sit a few other formats: FAT32 and exFAT for removable media, and ReFS for servers and storage pools. This lesson looks inside NTFS and compares it with the Linux file systems from the previous lesson.

Everything is a record in the MFT

NTFS has no separate inode table and bitmaps in fixed places. Instead, almost everything is stored in one big file, the Master File Table ($MFT). Each file and folder gets one record (normally 1 KiB), and each record is a list of attributes:

Attribute Holds Linux ext4 equivalent
$STANDARD_INFORMATION Timestamps, DOS attributes (read-only, hidden, system) Inode times and flags
$FILE_NAME Name and parent folder (a file can have several: hard links, the 8.3 short name) Directory entry
$DATA The contents. Small: inside the record (resident). Large: a list of cluster runs Inline data / extents
$SECURITY_DESCRIPTOR (via $Secure) Owner and ACL Mode bits + ACL xattrs
$INDEX_ROOT / $INDEX_ALLOCATION A folder's entries as a B+ tree Directory (htree)

Even the file system's own structures are files with MFT records: $MFT itself (record 0), $LogFile (the journal), $Bitmap (free clusters), $Boot, $Volume, $UpCase. They are hidden from Explorer but they are ordinary records, which makes NTFS very uniform.

The program below models MFT records. A file of up to roughly 700 bytes fits inside its record and needs no clusters at all; a bigger file gets data runs (start cluster, length), NTFS's word for extents.

python · try it yourself
CLUSTER = 4096
RECORD_SPACE = 700           # bytes left for resident data in a 1 KiB record (approximate)
mft = []                      # list of records; index = MFT record number
next_free_cluster = 1000

def add_record(name, parent, size=0, folder=False):
    global next_free_cluster
    rec = {"no": len(mft), "attrs": {"$STANDARD_INFORMATION": "times, flags",
                                     "$FILE_NAME": f"{name} (parent {parent})"}}
    if folder:
        rec["attrs"]["$INDEX_ROOT"] = "folder entries"
    elif size <= RECORD_SPACE:
        rec["attrs"]["$DATA"] = f"resident, {size} bytes inside the record"
    else:
        clusters = -(-size // CLUSTER)                  # round up
        runs = []
        while clusters:                                 # pretend free space comes in 64-cluster pieces
            n = min(clusters, 64)
            runs.append((next_free_cluster, n))
            next_free_cluster += n + 10                 # leave a gap: the file becomes fragmented
            clusters -= n
        rec["attrs"]["$DATA"] = f"non-resident, runs {runs}"
    mft.append(rec)
    return rec["no"]

for sysfile in ["$MFT", "$MFTMirr", "$LogFile", "$Volume", "$AttrDef", "."]:
    add_record(sysfile, 5, folder=(sysfile == "."))
users = add_record("Users", 5, folder=True)
note = add_record("note.txt", users, size=120)
video = add_record("clip.mp4", users, size=300_000)

for no in (5, users, note, video):
    print(f"record {no}:")
    for name, value in mft[no]["attrs"].items():
        print(f"   {name:22} {value}")
record 5:
   $STANDARD_INFORMATION  times, flags
   $FILE_NAME             . (parent 5)
   $INDEX_ROOT            folder entries
record 6:
   $STANDARD_INFORMATION  times, flags
   $FILE_NAME             Users (parent 5)
   $INDEX_ROOT            folder entries
record 7:
   $STANDARD_INFORMATION  times, flags
   $FILE_NAME             note.txt (parent 6)
   $DATA                  resident, 120 bytes inside the record
record 8:
   $STANDARD_INFORMATION  times, flags
   $FILE_NAME             clip.mp4 (parent 6)
   $DATA                  non-resident, runs [(1000, 64), (1074, 10)]

Record 5 is the root folder on every real NTFS volume too. On Windows you can see the MFT's size and the cluster size with fsutil (run as administrator; sample output, yours will differ):

cmd
C:\Users\ada>fsutil fsinfo ntfsinfo C:
NTFS Volume Serial Number :        0x5a2c8e1f2c8df3a1
NTFS Version      :                3.1
Number Sectors    :                0x000000003b9e6fff
Total Clusters    :                0x0000000007733dff
Free Clusters     :                0x0000000002f1c8a4
Bytes Per Sector  :                512
Bytes Per Physical Sector :        4096
Bytes Per Cluster :                4096
Bytes Per FileRecord Segment    :  1024
Mft Valid Data Length :            0x0000000032c40000
Mft Zone Start    :                0x0000000000c7e420
Mft Zone End      :                0x0000000000c8a820

Alternate data streams

An NTFS file can have more than one $DATA attribute. The unnamed one is the normal content; named ones are alternate data streams (ADS). Browsers use one called Zone.Identifier to remember that a file came from the Internet, which is what makes Windows show "This file came from another computer" (sample session):

powershell
PS C:\Users\ada> Get-Item .\Downloads\setup.exe -Stream *

FileName: C:\Users\ada\Downloads\setup.exe

Stream                   Length
------                   ------
:$DATA                  5242880
Zone.Identifier              26

PS C:\Users\ada> Get-Content .\Downloads\setup.exe -Stream Zone.Identifier
[ZoneTransfer]
ZoneId=3
PS C:\Users\ada> Unblock-File .\Downloads\setup.exe     # removes the stream

Streams survive only on NTFS. Copy the file to a FAT32 stick, or to a Linux ext4 disk, and they are silently lost.

Other NTFS features

Feature What it does Command
Journaling $LogFile records metadata changes, replayed after a crash automatic; chkdsk for repairs
ACLs Fine-grained permissions per user/group icacls, Get-Acl (Windows Users, UAC & ACLs)
Compression Transparent per-file compression compact /c file
EFS encryption Per-file encryption tied to the user cipher /e folder
BitLocker Whole-volume encryption (below NTFS) manage-bde -status
Hard links, symlinks, junctions Several names / pointers for one file or folder mklink (Links, Inodes & File Metadata)
Volume Shadow Copy Point-in-time snapshots used by backups and System Restore vssadmin list shadows
USN change journal A log of every file change, used by search and backup tools fsutil usn queryjournal C:
Case Case-preserving but case-insensitive by default; per-folder case sensitivity exists for WSL fsutil file setCaseSensitiveInfo

FAT32, exFAT and ReFS

FAT (File Allocation Table) is the oldest and simplest: a table with one entry per cluster, each pointing to the next cluster of the same file, ending with an end-of-chain marker. Reading a file means following the chain:

python · try it yourself
EOF = -1
fat = {2: 3, 3: 4, 4: 9, 9: EOF,       # report.docx: 2 -> 3 -> 4 -> 9
       5: 6, 6: EOF,                    # photo.jpg:   5 -> 6
       7: 0, 8: 0, 10: 0}               # 0 = free cluster
directory = {"REPORT.DOCX": 2, "PHOTO.JPG": 5}

def chain(start):
    clusters = [start]
    while fat[clusters[-1]] != EOF:
        clusters.append(fat[clusters[-1]])
    return clusters

for name, first in directory.items():
    print(f"{name:12} clusters {chain(first)}")
print("free clusters:", [c for c, nxt in sorted(fat.items()) if nxt == 0])
REPORT.DOCX  clusters [2, 3, 4, 9]
PHOTO.JPG    clusters [5, 6]
free clusters: [7, 8, 10]

There are no owners, no permissions and no journal in that table, which is why FAT is universal but fragile.

FAT32 exFAT NTFS ReFS
Typical use Small USB sticks, EFI System Partition SD cards, large USB drives Windows system and data drives Servers, Storage Spaces, Dev Drive
Max file size 4 GiB − 1 byte 16 EiB 16 TiB (256 TiB on newer Windows) 35 PB
Journal No No Yes Copy-on-write + integrity streams
Permissions No No ACLs ACLs
Read/write on Linux Yes (vfat) Yes (exfat) Yes (ntfs3) No
Read/write on macOS Yes Yes Read only (without extra tools) No
Windows can boot from it No No Yes No

The 4 GiB limit of FAT32 is the classic reason a movie "won't copy" to a USB stick: reformat it as exFAT. ReFS (Resilient File System) checksums its metadata (and optionally data), repairs from mirror copies, and is the format behind Windows 11's Dev Drive for source code; it still lacks some NTFS features such as EFS and cannot hold the Windows system itself.

Formatting on Windows (sample session; it erases the drive):

powershell
PS C:\Users\ada> Format-Volume -DriveLetter E -FileSystem exFAT -NewFileSystemLabel MUSIC

DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining     Size
----------- ------------ -------------- --------- ------------ ----------------- -------------     ----
E           MUSIC        exFAT          Removable Healthy      OK                     57.69 GB 57.73 GB

NTFS versus ext4

Topic NTFS ext4
Per-file metadata MFT record (1 KiB) with attributes Inode (256 bytes)
Names $FILE_NAME in the record + folder index Directory entries only
Tiny files Resident inside the MFT record Inline data (optional feature)
Allocation Clusters, data runs Blocks, extents
Journal $LogFile (metadata) jbd2 (metadata by default)
Permissions ACLs rwx bits + optional POSIX ACLs
Case sensitivity Insensitive (preserving) Sensitive
Forbidden in names \ / : * ? " < > | and names like CON, NUL, COM1 Only / and the NUL byte
Extra streams Alternate data streams Extended attributes (xattrs)

The name rules matter when sharing files: notes:v2.txt and README plus readme are fine on Linux, but cannot coexist on a Windows disk.

Learn more: File System Concepts · The Windows Folder Layout · Batch: attrib

Test yourself

Where does NTFS store the contents of a 200-byte text file?

  1. In a separate 4 KiB cluster
  2. Inside the file's MFT record, as a resident $DATA attribute
  3. In $LogFile
  4. In the folder's index

A 6 GB video will not copy to a USB stick. Which format is the stick most likely using?

  1. exFAT
  2. NTFS
  3. FAT32
  4. ReFS

What is the Zone.Identifier alternate data stream used for?

  1. Storing the file's ACL
  2. Marking that a file was downloaded from the Internet
  3. Holding the file's short 8.3 name
  4. Recording the journal