Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Google   


Windows NTFS filesystem internals

News See also Recommended Links Tutorials Disk Repartitioning Windows Filesystems Recovery Etc

NTFS is the preferred file system on Windows NT family, including Windows XP, Windows 2000, Windows 2003 and Windows NT. It  address many of the limitations of the earlier FAT16 and FAT32 file systems. The most important features are as follows:

Other advanced features provided by NTFS are the following:

Recommended Links

Services for UNIX - Interoperability

GID on NTFS File System

Can you set group on a file or folder on NTFS file system? - No, ugh... Yes.

This question puzzled me for a long time but since it never really made it to my top priorities, I didn't look up for information on this. I thought of exploring this area more while I was researching something about NFS server.

I started with looking for the utilities (obviously, Windows-based ones) which can set this information for me. My search ended quickly with the chown.exe and chgrp.exe which you can install with Interix/SUA Base Utilities.

Using Process Monitor (replacement of Filemon and Regmon utilities) revealed that group information gets stored on the file system with an IRP_MJ_SET_SECURITY request -

The other interesting fact is this request originating from the POSIX subsystem (psxss.exe) which makes sense because chown.exe and chgrp.exe utilities are POSIX subsystem utilities.

This KB Article says -

In the Windows NT and Windows 2000 NTFS file system, each file also has an owner and a primary group. The primary group of a file is not used by the Win32 subsystem, but is present for programs that make use of the POSIX subsystem. When a file is created, the user who created the file becomes its owner and that user's primary group becomes the file's primary group. Access Control Entries (ACEs) are then added to the DACLs to assign permissions.

That makes it clear that none of other utilities I tried to use, could set this information because they were basically Win32 binaries and Win32 subsystem does not, in anyway, uses this information.

So the best practice would be to set correct primary groups for your users and then use Interix/SUA chown.exe and chgrp.exe utilities to manage them the way you want them to be seen by your UNIX clients.

Additional Note: The ls.exe and chmod.exe are other utilities which can help you do things the UNIX way.

NTFS5 vs. FAT32

Win2K File-System Facts
Compatibility with legacy file systems is an important aspect of OS upgrades. Win2K supports several file systems, and its support is essentially a superset of NT 4.0's support. (For more information about file systems, see "File-System Resources," page 104.) Win2K still supports FAT12, FAT16, and the CD-ROM File System (CDFS), which is the International Organization for Standardization (ISO)-9660-compliant NT file system you use to read CD-ROMs. However, Microsoft doesn't plan to add features or upgrade these systems, except for a possible future addition of support for the UNIX-centric Rock Ridge format in CDFS. NTFS, which is the premier Win2K file system, continues to exist but sports a new file-system structure and new capabilities. Microsoft also included in Win2K a Universal Disk Format (UDF) file system that the company introduced in Windows 98. Currently, Win2K's UDF version, which complies with the ISO-13346 standard, mainly supports DVD-ROM media. However, Microsoft plans to eventually replace the CD-ROM-centric CDFS specification with UDF. Win2K also supports a slightly more recent version of UDF (i.e., UDF 1.50) than Win98 supports (i.e., UDF 1.02).

NTFS.com NTFS File System General Information. Data Recovery

Exploring NTFS On-disk Structures

NTFS FAQ (en)

Microsoft/NTFS overview

NTFS Read-only NTFS support.

Systems Internals -- very useful site with a lot of utilities with source code. Makers of NTFSDOS -- NTFS driver for DOS and other interesting tools for NT recovery

File System Usage in Windows NT 4.0 - by Wemer Vogels - 2.15M .PDF
This paper discusses real world traces of filesystem usage. It shows how certain real world behaviors are important to optimize for and shows how NT succeeds (partially) at providing good filesystem performance.

PartitionMagic - Product Information -- nice utility to convert NTFS into something else

Tutorials

[PPT] Windows Kernel Internals NTFS

ntfsdoc - What is ntfsdoc

NTFS - Wikipedia, the free encyclopedia

Windows NT File System Internals: A Developer's Guide: Chapter 4. ...

Inside NTFS

NTFS streams

NTFS File System Internals - DECUS San Diego

Inside Win2K NTFS, Part 2

NTFS.com NTFS Format. Master File Table (MFT). General Information ...

The Delphi Magazine Issue 98 Sample Article/NTFS Compression And Sparse Filesby Marcel van Brakel This article first appeared in The Delphi Magazine Issue 98 (October 2003)

How could space not be infinite? Is there a sign somewhere
saying ‘Space Ends Here – Mind the Gap’?      (Max Tegmark)

Hard disks keep getting larger every year, but after a while even the largest hard disks just don’t cut it any more. My first PC had a 425Mb hard disk, and I was sure I’d never run out of space. Two years later I found myself looking for a second disk. My second PC had a 4Gb hard disk, and this time I just knew I’d never run out of disk space. Two years later I found myself looking for a second disk. My current PC has a 40Gb hard disk, and now, a year after purchase, it’s 75% full. At most companies I’ve worked for the exact same thing happens. When purchased the storage devices seem to have infinite space, but before long the limits of infinity are reached. Buying additional, or larger, disks or moving unused files to offline storage, are two possible ways to solve this problem. Compression is another.

Ever since Windows NT 3.51, the Windows NT File System (NTFS) has had native support for file compression. While very useful, this generic compression is not without drawbacks. Compression and decompression consume precious processor cycles and, because it uses a generic compression algorithm (Lempel-Ziv), it may not guarantee you the best possible compression ratio. With NTFS version 5 (introduced with Windows 2000) Microsoft has added another, specialised means of compression known as sparse files. In this article we’ll look at both of these compression methods and how you use them from a programmer’s perspective.

NTFS Internals

To fully understand how compression and sparse files work we need to take a peek inside NTFS. NTFS uses disk clusters as its basic unit of storage. Depending on how the volume was formatted, a cluster may span one or more disk sectors. This means that when NTFS reads from or writes to a disk, it always does so using at least one cluster. Even if you create a one-byte file, the file will occupy a full cluster on the disk. Each cluster is identified using a Logical Cluster Number (LCN). The first cluster has LCN 0, the second LCN 1, and so forth.

A file’s data will span one or more clusters on disk, which may not be physically contiguous but could be viewed as such logically. NTFS numbers these logical clusters belonging to a file using a Virtual Cluster Number (VCN). The first logical cluster of a file has VCN 0, the second VCN 1, and so forth. NTFS doesn’t keep track of each individual cluster that belongs to a file but instead manages them using the concept of a run (sometimes called an extend). A run is just a set of one or more clusters that have contiguous LCNs. Each run can be managed by storing its starting LCN and the count of clusters in that run. NTFS does exactly that: for each file it maintains a list of LCN and count pairs identifying the runs in which the file data is stored. The only missing piece is that NTFS needs to be able to translate an offset into a file into the LCN where it’s stored. For this purpose NTFS also stores a VCN to LCN mapping (an offset into a file can be converted to a VCN simply by dividing the offset by the cluster size). The whole concept of LCNs, VCNs and mapping structures is summarised in Figure 1. The file described therein has 8 clusters stored in two runs: four cluster each (runs aren’t required to be four clusters, it’s just an example).

 


Copyright © 1996-2007 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: February 28, 2008