Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

If I'm going to copy a hard drive or create a VHD, should I defrag the source drive first or does it not matter?

Fragmentation, as I understand it, is a result of non optimal writes so I'm not sure what difference defraging a source would have?

share|improve this question
Need to know how you intend to "copy" disk image etc... – squarebear Jan 18 '13 at 9:07
Can you be more precise about what you mean by "create a VHD"? Are you asking if you should defragment a drive before making a VHD of that drive? It makes a difference if you're copying files or imaging. – David Schwartz Jan 18 '13 at 9:20
@David - Yes I was. To my mind it wouldn't make any difference. If I had a file with zero fragmentation and copy it that doesn't mean the target will also have zero fragmentation right? So id only hvae to defrag again. – rism Jan 19 '13 at 23:56
@rism: In the case of copying a file from one filesystem to another, whether the resulting file winds up fragmented or not has nothing to do with whether the source file was fragmented or not. To the destination filesystem, it's just open/write/close. – David Schwartz Jan 20 '13 at 0:47
@David - O.k so is this the difference between logical and physical copying. Physical copying you could benefit from a pre-defrag because it's going to be an exact copy, but logical copying i.e. though the OS, makes no difference because as you say it's open/write/close ? Or is that something else again? – rism Jan 21 '13 at 20:38
up vote 2 down vote accepted

Copying a file (assuming that there is enough unfragmented space that it can be written continuously, which with large files is a pretty big assumption) will defragment that file.

However, a virtual hard disk file may be fragmented on the inside the same way a real hard disk can be. This is solved by defragmenting the contents of the VHD, which simply copying the file(s) which make up the VHD outside of the virtualized environment will not do (any more than physically moving a hard disk from one computer to another will defragment it). Generally speaking, to the host operating system, the virtual hard disk is simply one or a few opaque, very large files, and won't be treated any different than, say, video files of a similar size.

There is a benefit to both host-based and guest-based defragmentation, if you are using a storage medium which benefits from defragmentation in the first place (spinning platter hard disks as opposed to SSDs or Flash memory). For best results, you would be well advised to do both. Guest side defragmentation can be done either before or after copying, but to gain the largest advantage I would do a host-side defragmentation after putting the virtual hard disk in its new place. Defragmenting prior to copying the file(s) may have a slight effect on the time to perform the copy operation, but almost certainly nowhere near enough to offset the time it actually takes to run the defragmentation.

share|improve this answer

If you are cloning the drive then yes, defrag, because cloning copies the exact structure of the files on the drive. If you are just copying files over then you don't need to defrag because copying files writes fresh on the new drive. Although defrag could make the copying go faster because it wouldn't have to search the first drive for parts of each file.

share|improve this answer

If you are doing a copy, then you dont need to worry about fragmentation. A "copy" reads the source file then writes to the destination. Regardless of the state of the original file, the output will be in non-fragmented state - as long as there is free, contiguous space.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .