Friday, May 9, 2014

Understanding Windows Master File Table (MFT) Allocation and Fragmentation

Well when you format a new hard drive (or it's pre-formatted) you are instructing your operating system you want to organize that disk using a specific format like Fat, Fat32, and New Technology File System (NTFS) which is the default disk format for Windows 8.1, Server 2012.



NTFS Architecture


But first, before you can format the disk you have to partition it. A partition contains a volume which can be formatted. Partition arouse to meet the requirement to split the a physical disk into many logical disk with other formats on them. 


A partition contains a Master Boot Record (MBR) and holds the information on how the logical partitions, containing file systems, are organized on that medium.














Sector zero will house the Master Boot Record (MBR), which contains the partition table.  The partition table will tell us where the partition will start and how big it is.  Once the partition is formatted a volume is created.  The volume starts at the first boot sector and ends at the last boot sector (aka backup boot sector). Now you can format the volume, in this case NTFS.

GUID Partition Table GPT Style














Instead of having a four line partition table, there is a 32 sector partition array.  This allows us to have more partitions as well as much larger partitions.  Also, there is a backup Partition Array out at the end of the drive.  This gives us partition information redundancy that MBR disks just don’t have.
The MS Reserved Partition marks off an area of the disk for Windows to use to store metadata that is not part of the file system.  Previously this metadata was stored in unprotected regions of the disk.
The volume is just like it was before.  It starts at the first boot sector and ends at the last. 
Keep in mind that in using GPT we are just changing how we define the box, not the contents of the box. Assuming that you are using NTFS, the file system is the same in both examples.  I can’t stress this enough.  There is no difference in NTFS between MBR and GPT.  In fact if you create a GPT disk smaller than 2 TB in size, a clever person could change the box with a sector editor, turn it into an MBR disk, and never alter the volume itself.  NTFS is blissfully unaware of what type box it lives in.
See GPT Dynamic here.

The Master File Table (MFT) executive private area responsible for organizing all you files on the disk, so they are accessed quickly and reliably on the disk.Sort of a database for files, which are stored in chunks called unit allocation size. This master "database" is called Master File Table (MFT).

That structure has a cost to it.

NTFS MFT Reservation ~ 12.5%


For NTFS, a slice of the HD that contains all file records i
s a called Master File Table (MFT).
Additionally, there are 
index and log files, that keep track of file changes on the disk, and is know as journaling file system. NTFS uses $LogFile to record metadata changes to the volume is is part of a whole slew of hidden NTFS meta-files.


By default NTFS reserves this zone, at 12.5%.


Please see How NTFS reserves space for its Master File Table (MFT) for full details, but states "NTFS reserves 12.5 percent of the volume for exclusive use of the MFT until and unless the remainder of the volume is completely used up."

However, when, for example, a lot of files are placed to the drive, MFT can grow beyond the reserved zone and becomes fragmented. 



Another reason is when you delete file, NTFS does not always use its space in MFT to store new one, it just marks MFT entry as deleted and allocates new entry for the new file. It provides some performance and recovery benefits, however it forces MFT to be fragmented.


The more MFT fragmentation, the more the HDD heads movements to access the data, the less overall performance of file system. A great article "
The Four Stages of NTFS File Growth" details this in great detail ;)

Starting from Windows NT 4.0 SP4 you can define MFT Zone Reservation value through the Registry.


Registry Key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem


Value NtfsMftZoneReservation of DWORD type (1 to 4) 

allows you to specify MFT Zone for the newly created/formatted volumes(12.5 percent, 25 percent, 37.5 percent, 50 percent of NTFS volume accordingly). 


For futher read  see Optimizing NTFS

No comments:

Post a Comment