NTFS (New Technology File System)

NTFS is Microsoft’s journaling file system for Windows NT and everything since. It is the default for Windows system and data volumes, from NT 3.1 through Windows 11 and Windows Server, and it is common on external drives and in virtual disks of Windows guests. The on-disk format has stayed at version 3.1 since 2001; Linux, macOS and BSD can read it, and deleted-file records often survive in the MFT, which makes it central to recovery work.

Overview

NTFS is a journaling, extent-based file system. Everything on a volume, including its own metadata, is a file. The central structure is the Master File Table ($MFT), an array of fixed-size file records. Each record holds typed attributes (name, timestamps, security, data, index entries). Small attributes are stored inside the record (resident); large ones live in clusters and are described by a list of data runs (non-resident). A file’s content is its unnamed $DATA attribute; named $DATA attributes are alternate data streams.

Directories are B-tree indexes of $FILE_NAME entries. Metadata changes are journaled in $LogFile. File names are UTF-16LE, timestamps are FILETIME (100 ns ticks since 1601-01-01 UTC), and all integers are little-endian. Optional features include LZNT1 compression, sparse files, EFS encryption, reparse points (symbolic links, junctions, mount points), hard links, quotas and the USN change journal.

History

  • Developed at Microsoft in the early 1990s for Windows NT (designers included Tom Miller, Gary Kimura, Brian Andrew and David Goebel); HPFS influenced its design.
  • 1993: Windows NT 3.1 ships the first version. NT 3.5, 3.51 and 4.0 followed with small revisions.
  • 2000: Windows 2000 introduces NTFS 3.0: quotas, EFS, sparse files, reparse points, the change journal, object IDs and $Extend.
  • 2001: Windows XP introduces NTFS 3.1 (still the current version); the file record header gained a record number field.
  • 2006-2007: Vista and Server 2008 add symbolic links, transactional NTFS (later deprecated) and self-healing.
  • 2021: the Paragon-developed ntfs3 driver is merged in Linux 5.15.

Key structures

Boot sector ($Boot, sector 0)

The first sector of the volume holds the BIOS parameter block and the start of the boot code. A backup copy is stored in the last sector of the volume. Total size 512 bytes.

OffsetSizeFieldDescription
0x003Jump instructionTypically EB 52 90
0x038OEM IDASCII “NTFS ” (four trailing spaces)
0x0B2Bytes per sectorUsually 512 or 4096
0x0D1Sectors per clusterPower of two. Values above 0x80 are interpreted as 2(256-n) sectors for very large clusters
0x0E2Reserved sectorsMust be 0
0x103Unused0 (FAT field)
0x132Unused0 (FAT small total sectors)
0x151Media descriptor0xF8 for fixed disks
0x162Unused0
0x182Sectors per trackBIOS geometry, typically 63
0x1A2Number of headsBIOS geometry, typically 255
0x1C4Hidden sectorsSectors before the partition
0x204Unused0 (FAT large total sectors)
0x244UnusedTypically 80 00 80 00
0x288Total sectorsSectors in the volume, not counting the backup boot sector
0x308$MFT start clusterLCN of the first cluster of $MFT
0x388$MFTMirr start clusterLCN of the first cluster of $MFTMirr
0x401Clusters per file recordSigned. Positive: number of clusters. Negative: record size is 2|n| bytes (for example 0xF6 = -10 = 1024 bytes)
0x413Unused0
0x441Clusters per index recordSame signed encoding as above
0x453Unused0
0x488Volume serial number64-bit random value
0x504ChecksumUsually 0 and not verified
0x54426Boot codeBootstrap loader
0x1FE2End-of-sector marker55 AA

MFT file record header

Each $MFT entry begins with this header. The update sequence array normally follows at offset 0x30 (NTFS 3.1) and attributes follow after it.

OffsetSizeFieldDescription
0x004SignatureASCII “FILE”; “BAAD” marks a record that failed a consistency check
0x042Update sequence array offsetTypically 0x30
0x062Update sequence array sizeNumber of 16-bit entries, including the USN itself (3 for a 1024-byte record)
0x088$LogFile sequence numberLSN of the last journaled change
0x102Sequence numberIncremented each time the record is freed and reused
0x122Hard link countNumber of directory entries referring to this file
0x142First attribute offsetOffset of the first attribute header
0x162Flags0x0001 in use, 0x0002 directory
0x184Used sizeBytes of the record actually in use (including header)
0x1C4Allocated sizeSize of the record on disk (for example 1024)
0x208Base record reference0 for a base record; otherwise a file reference to the base record that owns this extension record
0x282Next attribute IDID to assign to the next attribute added
0x2A2PaddingNTFS 3.1+
0x2C4MFT record numberNTFS 3.1+: index of this record in $MFT

Attribute headers

Every attribute starts with a common header. The list ends with a four-byte end marker 0xFFFFFFFF in the type field. Attributes appear in ascending type order.

Common header (all attributes)
OffsetSizeFieldDescription
0x004TypeAttribute type code (see constants)
0x044LengthTotal attribute length including header; 8-byte aligned
0x081Non-resident flag0 = resident, 1 = non-resident
0x091Name lengthIn UTF-16 code units; 0 for an unnamed attribute
0x0A2Name offsetFrom the start of the attribute header
0x0C2Flags0x0001 compressed, 0x4000 encrypted, 0x8000 sparse
0x0E2Attribute IDUnique within the record
Resident attribute continuation
OffsetSizeFieldDescription
0x104Content lengthSize of the attribute value in bytes
0x142Content offsetFrom the start of the attribute header
0x161Indexed flag1 if the value is referenced by an index (for example $FILE_NAME)
0x171Padding
Non-resident attribute continuation
OffsetSizeFieldDescription
0x108Starting VCNFirst VCN described by this attribute record
0x188Last VCNLast VCN described by this attribute record
0x202Data runs offsetFrom the start of the attribute header
0x222Compression unit sizelog2 of clusters per compression unit (0 if not compressed; 4 means 16 clusters)
0x244Padding
0x288Allocated sizeBytes allocated to the data, a multiple of the cluster size
0x308Real sizeActual data size in bytes
0x388Initialized sizeBytes initialized; reads beyond this return zeros
0x408Compressed sizePresent only for compressed or sparse attributes

$STANDARD_INFORMATION (0x10)

Always resident. 48 bytes on NTFS 1.x, 72 bytes on NTFS 3.x.

OffsetSizeFieldDescription
0x008Creation timeFILETIME
0x088Last modification timeFILETIME (data modified)
0x108MFT change timeFILETIME (metadata modified)
0x188Last access timeFILETIME
0x204File attribute flagsSee file attribute flags in constants
0x244Maximum versions0 if versioning is not used
0x284Version number
0x2C4Class ID
0x304Owner IDNTFS 3.0+, used with quotas
0x344Security IDNTFS 3.0+, key into $Secure
0x388Quota chargedNTFS 3.0+
0x408Update sequence number (USN)NTFS 3.0+, last USN journal record for this file

$FILE_NAME (0x30)

Always resident and indexed. A file has one for each name (a DOS 8.3 name has its own entry). The same structure is the key of directory index entries.

OffsetSizeFieldDescription
0x008Parent directory referenceFile reference (48-bit record number plus 16-bit sequence)
0x088Creation timeFILETIME
0x108Last modification timeFILETIME
0x188MFT change timeFILETIME
0x208Last access timeFILETIME
0x288Allocated sizeOften 0 and not kept up to date
0x308Real sizeOften 0 and not kept up to date
0x384FlagsFile attribute flags; also 0x10000000 directory, 0x20000000 index view
0x3C4Reparse tag / EA sizeReparse tag if the reparse flag is set; otherwise extended attribute size
0x401Name lengthIn UTF-16 code units
0x411Namespace0 POSIX, 1 Win32, 2 DOS, 3 Win32 and DOS
0x422 x nNameUTF-16LE, not NUL-terminated

$ATTRIBUTE_LIST (0x20) entry

Present when a file’s attributes do not fit in one record. It lists the attributes and the record that holds each one. Entries are packed one after another.

OffsetSizeFieldDescription
0x004Attribute type
0x042Entry lengthIncludes the name; 8-byte aligned
0x061Name lengthUTF-16 code units
0x071Name offsetNormally 0x1A
0x088Starting VCNFirst VCN of the attribute chunk in the referenced record
0x108File referenceMFT record that holds the attribute
0x182Attribute ID
0x1A2 x nNameUTF-16LE, if named

$OBJECT_ID (0x40)

Resident. Only the first field is always present; the others may be absent (length 16, 32, 48 or 64).

OffsetSizeFieldDescription
0x0016Object IDGUID unique on the volume
0x1016Birth volume IDGUID of the volume on which the file was created
0x2016Birth object IDOriginal object ID
0x3016Domain IDReserved

$VOLUME_INFORMATION (0x70)

Resident, 12 bytes, found only in the $Volume file (record 3).

OffsetSizeFieldDescription
0x008Reserved0
0x081Major version3 on NTFS 3.x
0x091Minor version0 or 1
0x0A2Volume flags0x0001 dirty (checked at next mount), 0x0002 resize $LogFile, 0x0004 upgrade on mount, 0x0008 mounted on NT 4, 0x0010 deleting USN journal, 0x0020 repair object IDs, 0x8000 modified by chkdsk

Data runs (non-resident attributes)

A run list is a packed sequence of variable-length entries stored at the data-runs offset of a non-resident attribute. It ends with a single 0x00 byte.

OffsetSizeFieldDescription
0x001Header byteLow nibble L = bytes in the length field; high nibble O = bytes in the offset field
0x01LRun lengthUnsigned, in clusters
0x01+LORun offsetSigned, relative to the previous run’s starting LCN (absolute for the first run). O = 0 means a sparse run with no allocated clusters

Example: 21 18 34 56 00 is one run of 0x18 clusters starting at LCN 0x5634. The header 21 means a 1-byte length (18) and a 2-byte offset (34 56 = 0x5634 little-endian), and 00 ends the list.

Indexes: $INDEX_ROOT, $INDEX_ALLOCATION and INDX records

Directories are B-trees. The root node lives in a resident $INDEX_ROOT (named $I30 for directories); overflow nodes live in INDX records inside the non-resident $INDEX_ALLOCATION, tracked by a $BITMAP.

$INDEX_ROOT (0x90) value header
OffsetSizeFieldDescription
0x004Indexed attribute type0x30 for file-name indexes; 0 for non-attribute indexes
0x044Collation ruleSee constants
0x084Bytes per index recordTypically 4096
0x0C1Clusters per index recordSame encoding as in the boot sector
0x0D3Padding
0x1016Index node headerSee below
Index node header (16 bytes)
OffsetSizeFieldDescription
0x004First entry offsetRelative to the start of this node header
0x044Total size of entriesUsed bytes, including this header
0x084Allocated size
0x0C1Flags0x01 large index (entries exist in $INDEX_ALLOCATION)
0x0D3Padding
INDX record header (precedes an index node header in $INDEX_ALLOCATION)
OffsetSizeFieldDescription
0x004SignatureASCII “INDX”
0x042Update sequence array offsetTypically 0x28
0x062Update sequence array sizeEntries including the USN (9 for a 4096-byte record)
0x088$LogFile sequence number
0x108This record’s VCNVCN within $INDEX_ALLOCATION
0x1816Index node headerAs above; entry offsets are relative to 0x18
Index entry (directory entries use a $FILE_NAME structure as the key)
OffsetSizeFieldDescription
0x008File referenceMFT reference of the file this entry names
0x082Entry lengthTotal, 8-byte aligned
0x0A2Key lengthSize of the key that follows
0x0C2Flags0x01 entry has a sub-node, 0x02 last entry in the node (carries no key)
0x0E2Padding
0x10nKeyFor directories a $FILE_NAME attribute value
end-88Sub-node VCNPresent only if the sub-node flag is set; VCN of the child INDX record

$REPARSE_POINT (0xC0)

Marks a file or directory whose handling is delegated to a file system filter. The tag identifies the owner (symbolic link, junction, WOF and so on).

OffsetSizeFieldDescription
0x004Reparse tagSee reparse tags in constants
0x042Reparse data lengthBytes of tag-specific data
0x062Reserved
0x08nReparse dataTag-specific; for non-Microsoft tags a 16-byte GUID precedes the data

USN journal record (USN_RECORD_V2)

Records stored in the $J stream of $Extend\$UsnJrnl, used by search indexers, backup and sync software to find changed files. Records are 8-byte aligned.

OffsetSizeFieldDescription
0x004Record lengthTotal, including the name
0x042Major version2
0x062Minor version0
0x088File referenceFile this change concerns
0x108Parent file reference
0x188USNOffset of this record in the journal stream
0x208TimestampFILETIME
0x284Reason flagsBit mask of changes (data overwrite, create, delete, rename and so on)
0x2C4Source info
0x304Security ID
0x344File attributesFile attribute flags
0x382File name lengthIn bytes
0x3A2File name offsetNormally 0x3C
0x3CnFile nameUTF-16LE

Structures

Offsets are in bytes from the start of the structure named in each heading. Field names are descriptive and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.

Decompress

OffsetSizeTypeFieldNotes
inPos2u16 LEHeader
inPos2u16 LE–

Add Name Links

OffsetSizeTypeFieldNotes
0x08u64 LE–
0x401u8Length
0x411u8–

Build Entry

OffsetSizeTypeFieldNotes
0x88u64 LECreated
0x108u64 LEOdified
0x188u64 LEChanged
0x208u64 LEAccessed
0x384u32 LEFile Attributes

Build Entry

OffsetSizeTypeFieldNotes
0x08u64 LECreated
0x88u64 LEOdified
0x108u64 LEChanged
0x188u64 LEAccessed
0x204u32 LEFile Attributes

Parse Reparse Target

OffsetSizeTypeFieldNotes
0x82u16 LESubstitute Offset
0xA2u16 LESubstitute Length
0xC2u16 LEPrint Offset
0xE2u16 LEPrint Length

Load Attributes

OffsetSizeTypeFieldNotes
position + 42u16 LELength
position + 168u64 LEReferenced

Ntfs File System

OffsetSizeTypeFieldNotes
0x81u8Version
0x91u8Version
0xA2u16 LEIs Dirty

Try Parse

OffsetSizeTypeFieldNotes
0x38bytes–
0xB2u16 LEBytes Per Sector
0xD1u8Raw Sectors Per Cluster
0x288u64 LETotal Sectors
0x308u64 LEFt Cluster
0x388u64 LEFt Mirr Cluster
0x401u8Raw Record Size
0x488u64 LESerial Number

Apply Fixups

OffsetSizeTypeFieldNotes
0x42u16 LEOffset
0x62u16 LECount
end2u16 LE–
offset2u16 LESequence
end + 11u8–

Parse

OffsetSizeTypeFieldNotes
0x04u32 LE–
0x102u16 LESequence
0x142u16 LEFirst Attribute
0x162u16 LEFlags
0x184u32 LEBytes In Use
0x208u64 LEBase Reference
position4u32 LEType
position + 44u32 LELength

Parse Attribute

OffsetSizeTypeFieldNotes
0x04u32 LEType
0x81u8Non Resident
0x91u8Name Length
0xA2u16 LEName Offset
0xC2u16 LEFlags
0xE2u16 LEId
0x104u32 LEValue Length
0x108u64 LEStart Vcn
0x142u16 LEValue Offset
0x202u16 LERun Offset
0x222u16 LECompression Unit
0x288u64 LEAllocated Size
0x308u64 LEData Size
0x388u64 LEInitialized Size

Other fields read

Read inOffsetSizeTypeFieldNotes
Decompress Chunkposition2u16 LEToken
Build Entry0x04u32 LETag
Has File Record0x04u32 LE–

Constants

Mft Index

NameValueTypeNotes
StateValid1byte
StateInUse2byte
StateDirectory4byte
StateExtension8byte

Ntfs Const

NameValueTypeNotes
FileMagic0x454C4946uint“FILE”
FixupStride512int

Well-known MFT records

NameValueTypeNotes
MftRecord0uint
MftMirrRecord1uint
VolumeRecord3uint
RootRecord5uint
BitmapRecord6uint
FirstUserRecord16uint

MFT record header flags

NameValueTypeNotes
RecordInUse0x1ushort
RecordIsDirectory0x2ushort

Attribute types

NameValueTypeNotes
AttrStandardInformation0x10uint
AttrAttributeList0x20uint
AttrFileName0x30uint
AttrVolumeName0x60uint
AttrVolumeInformation0x70uint
AttrData0x80uint
AttrReparsePoint0xC0uint
AttrEnd0xFFFFFFFFuint

Attribute header flags

NameValueTypeNotes
AttrFlagCompressed0x0001ushort
AttrFlagEncrypted0x4000ushort
AttrFlagSparse0x8000ushort

$FILE_NAME namespaces

NameValueTypeNotes
NamespacePosix0byte
NamespaceWin321byte
NamespaceDos2byte
NamespaceWin32AndDos3byte

Windows file attributes ($STANDARD_INFORMATION)

NameValueTypeNotes
FileReadOnly0x1uint
FileHidden0x2uint
FileSystem0x4uint
FileArchive0x20uint
FileSparse0x200uint
FileReparsePoint0x400uint
FileCompressed0x800uint
FileEncrypted0x4000uint

Reparse tags

NameValueTypeNotes
ReparseMountPoint0xA0000003uint
ReparseSymlink0xA000000Cuint
RecordNumberMask0x0000FFFFFFFFFFFFulong

Implementation limits

ClassNameValueNotes
Lznt1ChunkSize4096
Ntfs File SystemMaxExtensionRecords4096
Ntfs File SystemMaxBitmapBytes512L * 1024 * 1024
Ntfs File SystemMaxRecoverabilityClusters16L * 1024 * 1024
Ntfs File SystemScanChunkBytes4 * 1024 * 1024
Ntfs File SystemMaxCachedRecords4096
Lemax2650467743999999999DateTime.MaxValue as a FILETIME
Ntfs File RecordMaxAttributes1024

Signatures and magic strings referenced

TextWhere checked
NTFS Try Parse

Common constants (reference)

Attribute type codes

CodeNamePurpose
0x10$STANDARD_INFORMATIONTimestamps, file attribute flags, security ID, quota
0x20$ATTRIBUTE_LISTLocations of attributes spread over several records
0x30$FILE_NAMEName, parent directory, duplicate timestamps
0x40$OBJECT_IDGUID for link tracking (NTFS 3.0+; was $VOLUME_VERSION in NTFS 1.x)
0x50$SECURITY_DESCRIPTORLegacy per-file security (NTFS 3.0+ uses $Secure)
0x60$VOLUME_NAMEVolume label, UTF-16LE
0x70$VOLUME_INFORMATIONNTFS version and volume flags
0x80$DATAFile content or an alternate data stream
0x90$INDEX_ROOTRoot node of an index
0xA0$INDEX_ALLOCATIONNon-root index nodes (INDX records)
0xB0$BITMAPAllocation bitmap of an MFT or index
0xC0$REPARSE_POINTReparse data (symlinks, junctions, mount points)
0xD0$EA_INFORMATIONExtended attribute summary
0xE0$EAExtended attributes
0x100$LOGGED_UTILITY_STREAMEFS and other logged data
0xFFFFFFFFEnd markerTerminates the attribute list in a record

System files (first MFT records)

RecordNamePurpose
0$MFTThe master file table itself
1$MFTMirrBackup of the first four $MFT records
2$LogFileMetadata transaction journal
3$VolumeVolume name, version and flags
4$AttrDefAttribute type definitions
5. (root)Root directory of the volume
6$BitmapCluster allocation bitmap
7$BootBoot sector and boot code
8$BadClusBad cluster list (sparse $Bad stream)
9$SecureShared security descriptors (NTFS 3.0+)
10$UpCaseUnicode upper-case mapping table
11$ExtendDirectory holding $ObjId, $Quota, $Reparse, $UsnJrnl, $RmMetadata
12-15(reserved)Marked in use but empty
16+Ordinary filesThis implementation treats record 16 as the first user record; on Windows-formatted volumes ordinary files normally start at 24

File record flags (MFT header, offset 0x16)

ValueMeaning
0x0001Record in use
0x0002Record is a directory

File attribute flags ($STANDARD_INFORMATION, $FILE_NAME)

ValueMeaning
0x00000001Read-only
0x00000002Hidden
0x00000004System
0x00000020Archive
0x00000040Device
0x00000080Normal
0x00000100Temporary
0x00000200Sparse file
0x00000400Reparse point
0x00000800Compressed
0x00001000Offline
0x00002000Not content indexed
0x00004000Encrypted
0x10000000Directory (in $FILE_NAME only)
0x20000000Index view (in $FILE_NAME only)

Attribute header flags (offset 0x0C)

ValueMeaning
0x0001Compressed (LZNT1)
0x4000Encrypted (EFS)
0x8000Sparse

$FILE_NAME namespaces

ValueNamespaceNotes
0POSIXCase-sensitive, nearly all Unicode characters allowed
1Win32Case-insensitive, long name
2DOS8.3 short name
3Win32 and DOSLong name that is also a valid 8.3 name; one entry serves both

Index collation rules

ValueRuleUsed by
0x00000000BinaryGeneric
0x00000001File name (case-insensitive Unicode)Directories ($I30)
0x00000002Unicode stringGeneric
0x00000010Unsigned 32-bit integer$Quota $Q
0x00000011SID$Quota $O
0x00000012Security hash, then ID$Secure $SDH
0x00000013Sequence of unsigned 32-bit integers$ObjId $O, $Reparse $R

Common reparse tags

ValueNameMeaning
0xA0000003IO_REPARSE_TAG_MOUNT_POINTJunction or volume mount point
0xA000000CIO_REPARSE_TAG_SYMLINKSymbolic link
0x80000013IO_REPARSE_TAG_DEDUPData Deduplication
0x80000017IO_REPARSE_TAG_WOFWindows Overlay Filter (compact OS, WIM boot)
0x8000001BIO_REPARSE_TAG_APPEXECLINKMicrosoft Store app execution alias

Other constants

ItemValue
Boot sector OEM ID“NTFS “
Boot sector signature0x55 0xAA at offset 0x1FE
MFT record signature“FILE” (46 49 4C 45); damaged: “BAAD”
Index record signature“INDX” (49 4E 44 58)
Directory index name$I30
Fixup stride512 bytes (the last 2 bytes of each stride hold the USN on disk)
Compression algorithmLZNT1, compression unit 16 clusters (default)
FILETIME epoch1601-01-01 00:00:00 UTC, units of 100 ns
File reference layoutbits 0-47 record number, bits 48-63 sequence number
Attribute alignment8 bytes
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.