Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to understand how defragmenting works so I can write my own program to do it. I was considering have it iterate through the files on the hard drive and defragment them each seperately. However, I came across a FAQ on a website for FragExt that states this:

Should I use FragExt to defragment all the files on my hard drive?

You can, but I don't advise that you do. A good volume defragmenter gives special consideration to usage relationships between different files, arranging them together and placing them at specific locations on the hard disk. Currently, FragExt simply looks for the first amount of free space large enough to defragment the file into and uses it. Future versions may include support for optimal placement patterns.

I'm wondering the reason behind this? And what exact "special consideration" should be given to determine where the cluster should be moved to?

share|improve this question

closed as too broad by Keltari, and31415, Nifle, BBlake, random May 22 '14 at 13:29

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

Reinventing the wheel, are we? There are typically patterns to accessing files. When taking these, and how mechanical disk drives work, into consideration, access can be sped up. – Daniel B May 22 '14 at 5:52
up vote 0 down vote accepted

For data drives the best (and positively the fastest!) way is copy its entire content to another, empty hard drive. All files are going to be defragmented to the fullest.

For system/boot drives image, then restore the image. Same result. In any other case you would defragment first to reduce image size, but your goal is to defragment so you may image without defragmenting first.

EDIT: Actually, you defrag first with disk cloning, to reduce the resulting size. With file-based imaging you would defrag first to reduce the process time. There is a difference between file-based imaging Windows use and disk-cloning Ghost or others use.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.