How do you defragment the MFT on an NTFS disk?

99,078

Solution 1

You can use the Sysinternals tool Contig:

contig.exe c:\$mft

Solution 2

Auslogics Disk Defrag Pro will accomplish this for you. Whilst not a free program, you can download a free trial, and if you do decide to purchase the license is available for use on up to three PCs.

Ultradefrag is a free and powerful FOSS defragmentation tool for the Windows Platform. It can defragment any system files including registry hives and paging file. It includes MFT optimization, which processes the MFT only.

Solution 3

Best tool by far was the old JKdefrag, now Mydefrag. Will defrag the MFT. Also, it's free.

The original site is down but one can source to get the latest version is here: https://www.techspot.com/downloads/3720-jkdefrag-mydefrag.html

edit

Windows Defrag API, used by MyDefrag, supports defragging the MFT.

Following are the system file, stream, and stream types supported by FSCTL_MOVE_FILE in "filename:streamname:$typename" format.

$MFT::$DATA $MFT::$ATTRIBUTE_LIST $MFT::$BITMAP

And MyDefrag's script documentation:

Inode   Filename    Description
0   $MFT    Master File Table - An index of every file.
1   $MFTMirr    A backup copy of the first 4 records of the MFT.
2   $LogFile    Transactional logging file.
3   $Volume Serial number, creation time, dirty flag.
4   $AttrDef    Attribute definitions.
6   $Bitmap Contains volume's cluster map (in-use vs. free).
7   $Boot   Boot record of the volume.
8   $BadClus    Lists bad clusters on the volume.
9   $Quota  [Windows NT only] Quota information.
9   $Secure Security descriptors used by the volume.
10  $UpCase Table of uppercase characters used for collating.
11  $Extend A directory for: $ObjId, $Quota, $Reparse, $UsnJrnl.
$Extend\$ObjId  Unique Ids given to every file.
$Extend\$Quota  Quota information.
$Extend\$Reparse    Reparse point information.
$Extend\$UsnJrnl    USN Journal.
$Extend\$RmMetadata Transactional data.

While it won't run on a Live CD, it will run on Bart PE or the Ultimate Windows BootCD.

But neither is necessary to defrag the MFT.

Solution 4

These steps worked for me:

  1. Run the MiniXP in Hiren's BootCD.
  2. Disable Hibernation, Virtual Memory and Kernel Memory Dump.
  3. Follow the instructions described in this link (use the fsutil).
  4. Run MyDefrag at MiniXP with the option "Consolidate free space".
  5. Start Windows again and now you can shrink you partition.
Share:
99,078

Related videos on Youtube

WBT
Author by

WBT

Updated on September 18, 2022

Comments

  • WBT
    WBT over 1 year

    A while ago, I nearly filled my hard drive, much more than the recommended maximum of 85% of capacity. I believe that NTFS started storing files in the space reserved for the Master File Table (MFT) and the MFT had to fragment elsewhere as it grew.
    I have cleared off space on the hard drive, but the MFT apparently remains fragmented, and there's a lot of slow disk access for even very simple operations like opening a folder or small file. This is killing performance. I remember that Windows standard disk defragmenter doesn't defragment the MFT because the MFT is in use when the operating system is running. I'm running Vista Ultimate and its defragment utility has very little in the way of reporting, less than older versions.

    I suspect that a solution might involve booting up from an optical disc with a basic OS ("Live CD") and running a defragment utility from that. Can anybody tell me what program to use, or how to defragment my MFT?

    Thanks!

  • WBT
    WBT over 12 years
    MyDefrag runs only on Windows; you can't run it from an open-source LiveCD. It claims to only remove files from the reserved MFT space, not to defragment the MFT if it's already fragmented. Is there another program [to be posted as a different answer] that can defragment the MFT?
  • surfasb
    surfasb over 12 years
    You are wrong. It's not explicit because the Defrag API supports defraging the MFT. Plus, you can check the MyDrag scripts.
  • BornToCode
    BornToCode about 11 years
    +1 Ultradefrag did miracles to me with a stubborn $MFT that even Contig (that got so many upvotes here) couldn't defeat
  • Fokpok
    Fokpok almost 8 years
    Didn't work for me. UltimateDefrag shows $MFT from a non-sytem partition is fragmented, but contig says "All files were either already defragmented or unable to be defragmented." Anyway I really don't know why theres is $MFT there.
  • Randall Flagg
    Randall Flagg almost 8 years
    the site is now: mydefrag.net
  • RockPaperLz- Mask it or Casket
    RockPaperLz- Mask it or Casket almost 8 years
    @BornToCode Any way to get Ultradefrag to not move files to the end of the partition when it optimizes the MFT?
  • KeithS
    KeithS almost 8 years
    @RockPaperLizard - I don't know, but the alternative to not moving those few files to the end is to shift every other file on the disk. You might try running ordinary Windows Defrag or Diskeeper after Ultradefrag; bear in mind however, that ordering every file by how many times it's used will be a long-running operation that will fall apart the next time you launch a web browser.
  • Alex
    Alex over 6 years
    jkdefrag and mydefrag are now dead - mydefragGUI can still be downloaded at mydefrag.net as the above comment shows but there has been no update since 2009
  • Daniel Sokolowski
    Daniel Sokolowski over 6 years
    I've read the author sold the software hence no updates. Having said that it is functionally complete and the best one it seems hence why I keep using it - hofmannc.de/en/windows-7-defragmenter-test/benchmarks.html
  • trlkly
    trlkly over 4 years
    Note that you'll now need to follow the download link to the "old versions," as the current version 8 is no longer FOSS.
  • Frederic Leitenberger
    Frederic Leitenberger over 4 years
    Note: I tried to do this in PowerShell on Windows 10 and all it kept doing was print the help. In the normal command shell it worked as expected. EDIT: I just found out why: The $ has special meaning in PS and needs escaping: contig.exe 'c:\$mft' works.
  • rustyx
    rustyx over 2 years
    Contig didn't work for me: Move cluster status: STATUS_INVALID_PARAMETER