Home » Questions » Computers [ Ask a new question ]

What does a defrag actually do?

What does a defrag actually do?

What does a defrag do really? Does it put the files that execute in sequence closer together?

Asked by: Guest | Views: 271
Total answers/comments: 3
Guest [Entry]

"Defragging can do two things:

Ensures all the pieces of a file are located in a continuous part of the hard drive. Most files are split into smaller ""fragments"" that are stuck wherever there is space. At first they will be stored continuously, but gaps/incontinuities will be created when files are deleted/modified. If a file is continuously stored, then it can be read faster.
Optimize the location on the harddrive (spinning harddrives only.) Hard drives are composed of spinning disk-shaped platters. The outside spins faster, so the harddrive will perform better when writing/reading near the outside of these platters because more data will be passing under the read/write head for a given time period.

Also, I'd like to add something about defragging SSD's:

Defragging an SSD

Long ago I promised to post on why
defragging an SSD is still relevant
and necessary. It’s true that with an
SSD there are no physical platters
that have to spin into place and no
read/write arms that have to move
wildly across the surface of a disk.
For this reason, it seems like
defragging is a waste of time. You
could also argue that since SSDs
eventually wear out, you should not
waste rewrite cycles on something as
simple as defragging your disk.

One of the facts about NAND flash
memory technology used in SSDs is that
writing data takes much longer than
reading data. When a file is erased,
much like standard hard disk
technology, only the directory
information is erased and the data
cells are marked “usable” again. The
data itself is still intact until
something new overwrites it.

This means that if the memory space is
in use with a “deleted” file, it must
first be erased before it can be
reprogrammed. If the free space is
fragmented, a new file must be broken
into several small write commands
instead of one larger write command.
This will cause a performance decrease
for SSDs because write speed is slow,
especially for small block write
transfers. Yes, cache memory helps
mask this performance issue, but no
matter what the technology, one long
write command is always better than
multiple short write commands.

Net, defrag your disk regularly if you
want maximum performance.

source: Inside the Box Lenovo blog"
Guest [Entry]

"Your file system will sometimes put parts of a file in different locations on the disk. When accessing this file later, it takes longer because it has to go to each of those locations to access the file. That is called fragmentation. Basically, you have fragments of your files in different places on the disk.

When you defragment the disk, you are rearranging the files on the disk so that as many files as possible are stored in their entirety."
Guest [Entry]

"It depends on the file system, the defragmenter, and the HDD/SSD.

Most files will be consolidated into one block each. That's the minimum requirement and definition of ""defragmenter"".

More advanced defragmenters will move directories first (since they are, on a per-megabyte average, accessed more frequently than ordinary files), followed by files accessed recently. Files which have not been accessed for a long time (typically 90 days) are sometimes actively placed closer to the end, to allow for shorter seeks for files which do get accessed.

NTFs seems to fragment only slightly less than FAT but to degrade more slowly if it is. Some of the important file are not at the front of the partition but near the middle, obviously to cut the worst case access time in half. Not sure about it, though.

The ""seek"" times on SSDs are minimal, on the order of microseconds. You're looking at the wrong places if you defrag SSDs for seeks. (An intelligent SSD controller could merely update WHERE the data are moved, rather than moving them, each time it detects the ""read old data + wite same data + TRIM old data"" pattern, economizing on both write cycles AND defrag runtime. Not sure if any controller does that yet.)

On a second thought, yes, SSDs distribute writes across chips on purpose, because that's how they are faster, and heavy fragmentation might slow the write patterns by making the writes LESS scattered. That might be a factor to consider if it's true.

Always, and regularly, do your backups. If you defrag disks for ease of data recovery, YOU'RE DOING IT WRONG!"