Defragmentation

From Wikipedia, the free encyclopedia

In the context of administering computer systems, defragmentation (or defragging) is a process that reduces the amount of fragmentation in file systems. It does this by physically reorganizing the contents of the disk in order to store the pieces of each file close together and in order (contiguously). It also attempts to create larger regions of free space using compaction to impede the return of fragmentation. Some defragmenters also try to keep smaller files within a single directory together, as they are often accessed in sequence.

Contents

[edit] Aims of defragmentation

Reading and writing data on a heavily fragmented file system is slowed down as the time needed for the disk heads to move between fragments, and waiting for the disk platter to rotate into position, is increased (see seek time and rotational delay). For many common operations, the performance bottleneck of the entire computer is the hard disk; thus the desire to process more efficiently encourages defragmentation. Operating system vendors often recommend periodic defragmentation in order to keep disk access speed from degrading over time.

Fragmented data also spreads over more of the disk than it needs to. Thus one may defragment in order to gather data together in one area, before splitting a single partition into two or more partitions (for example, with GNU Parted, or PartitionMagic).

Defragmenting may help to increase the life-span of the hard drive itself, by minimizing head movement and simplifying data access operations.[1] [2]

[edit] Causes and cures

Fragmentation occurs when the operating system cannot or will not allocate enough contiguous space to store a complete file as a unit, but instead puts parts of it in gaps between other files (usually those gaps exist because they formerly held a file that the operating system has subsequently deleted or because the operating system allocated excess space for the file in the first place). As advances in technology bring larger disk drives, the performance loss due to fragmentation squares with each doubling of the size of the drive.[citation needed] Larger files and greater numbers of files also contribute to fragmentation and consequent performance loss. Defragmentation attempts to alleviate these problems.

A defragmentation program must move files around within the free space available in order to undo fragmentation. This is a memory intensive operation and cannot be performed on a file system with no free space. The reorganization involved in defragmentation does not change logical location of the files (defined as their location within the directory structure).

Another common strategy to optimize defragmentation and to reduce the impact of fragmentation is to partition the hard disk(s) in a way that separates partitions of the file system that experience many more reads than writes from the more volatile zones where files are created and deleted frequently. In Microsoft Windows, the contents of directories such as "\Program Files" or "\Windows" are modified far less frequently than they are read. The directories that contain the users' profiles are modified constantly (especially with the Temp directory and Internet Explorer cache creating thousands of files that are deleted in a few days). If files from user profiles are held on a dedicated partition (as is commonly done on UNIX systems), the defragmenter runs better since it does not need to deal with all the static files from other directories. For partitions with relatively little write activity, defragmentation performance greatly improves after the first defragmentation, since the defragmenter will need to defrag only a small number of new files in the future.

[edit] Defragmentation issues

The presence of immovable system files (or of files that the defragmenter will not move in order to simplify its task), especially a swap file, can impede defragmentation. These files can be safely moved when the operating system is not in use. For example, ntfsresize moves these files in order to resize an NTFS partition.

On systems without fragmentation resistance, fragmentation builds upon itself when left unhandled, so periodic defragmentation is necessary to keep disk performance at peak and avoid the excess overhead of less frequent defragmentation.

[edit] Myths

Many Windows users believe that frequent defragmentation is necessary to maintain adequate system performance. Although it may produce substantial filesystem speed improvements in some cases, for the typical Windows user the overall performance improvement may be minor or unnoticeable. Unless the operating system is malfunctioning, it should not be necessary to defrag to keep the system from crashing; the filesystem is designed to work with fragmented files. In fact, in a modern multi-user operating system, an ordinary user cannot defragment the system disks since superuser access is required to move system files.

[edit] Utilities

Defragmentation programs often come bundled with an operating system (although Windows NT notably did not include one). Perhaps the best-known defragmentation utility is Windows Disk Defragmenter, which is currently based on an old version of Diskeeper.

Defragmentation utilities:

  • Diskeeper
  • Windows Disk Defragmenter
  • PerfectDisk
  • O&O Defrag
  • mst Defrag
  • UltimateDefrag
  • PageDefrag: Runs at startup and attempts to defragment system files that cannot be defragmented while they are in use.
  • Contig: A command-line based defragmentation utility.
  • Auslogics: A free defragmentation program for NTFS.
  • JkDefrag: A free (GPLed) disk defragment and optimize utility for Windows 2000/XP/2003/Vista.

[edit] Filesystems

  • FAT DOS 6.x and Windows 9x-systems come with a defragmentation utility called Defrag. The DOS version is a limited version of Norton SpeedDisk.
  • NTFS Windows 2000 and newer include an online defragmentation tool based on Diskeeper. NT 4 and below do not have built-in defragmentation utilities.
  • ext2 uses an offline defragmenter called e2defrag, which does not work with its successor ext3, unless the ext3 filesystem is temporarily down-graded to ext2.
  • JFS has a defragfs utility on IBM operating systems.
  • HFS Plus in 1998 introduced a number of optimizations to the allocation algorithms in an attempt to defragment files while they're being accessed without a separate defragmenter.
  • XFS provides an online defragmentation utility called xfs_fsr.

[edit] References

  • Jensen, Craig (1994). Fragmentation: The Condition, the Cause, the Cure. Executive Software International. ISBN 0-9640049-0-9.

[edit] Notes