Visualization of fragmentation and then of defragmentation

In the maintenance of file systems, defragmentation is a process that reduces the amount of fragmentation. It does this by physically organizing the contents of the mass storage device used to store files into the smallest number of contiguous regions (fragments). It also attempts to create larger regions of free space using compaction to impede the return of fragmentation. Some defragmentation utilities try to keep smaller files within a single directory together, as they are often accessed in sequence.

Defragmentation is advantageous and relevant to file systems on electromechanical disk drives. The movement of the hard drive's read/write heads over different areas of the disk when accessing fragmented files is slower, compared to accessing the entire contents of a non-fragmented file sequentially without moving the read/write heads to seek other fragments.


Causes of fragmentation

Fragmentation occurs when the file 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 file system allocated excess space for the file in the first place). Larger files and greater numbers of files also contribute to fragmentation and consequent performance loss. Defragmentation attempts to alleviate these problems.

File system fragmentation.svg

Consider the following scenario, as shown by the image on the right:

An otherwise blank disk has five files, A through E, each using 10 blocks of space (for this section, a block is an allocation unit of that system, it could be 1 KB, 100 KB or 1 MB and is not any specific size). On a blank disk, all of these files will be allocated one after the other. (Example (1) on the image.) If file B is deleted, there are two options, leave the space for B empty and use it again later, or move all the files after B so that the empty space is at the end. This could be time consuming if there were hundreds or thousands of files which needed to be moved, so in general the empty space is simply left there, marked in a table as available for later use, then used again as needed.[1] (Example (2) on the image.) When a new file, F, is allocated requiring six blocks of space, it can be placed into the first 6 blocks of the space formerly holding the file B and the four blocks following it will remain available. (Example (3) on the image.) If another new file, G is added, and needs only four blocks, it could then occupy the space after F and before C. (Example (4) on the image). When F needs to be expanded, since the space immediately following it is no longer available, there are two options:

  1. Move the file F to where it can be created as one contiguous file of the new, larger size. Relocating the file may not be possible as the file may be larger than any one contiguous space available. The file conceivably could be so large the operation would take an undesirably long period of time. Some filesystems relocate files as a background task with low priority.
  2. Add a new block somewhere else and indicate that F has a second extent (Example (5) on the image.) Repeat this hundreds of times and the file system has many free segments in many places and many files may be spread over many extents. When a new file (or a file which has been extended) has to be placed in a large number of extents, access time for that file may become excessively long.

The process of creating, deleting and expanding existing files, may be referred to as churn, and can occur at both the level of the general root file system or in subdirectories. Fragmentation not only occurs at the level of individual files, but also when different files in a directory (and maybe its subdirectories), that are often read in a sequence, start to "drift apart" as a result of "churn".

A defragmentation program must move files around within the free space available to undo fragmentation. This is an intensive operation and cannot be performed on a file system with no free space. Performance during this process will be severely degraded. Depending on the algorithm used it may advantageous to perform multiple passes. The reorganization involved in defragmentation does not change logical location of the files (defined as their location within the directory structure).

Common countermeasures


A 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. The directories that contain the users' profiles are modified constantly (especially with the Temp directory and web browser 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[citation needed]), 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.

Offline defragmentation

The presence of immovable system files, 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 to resize an NTFS partition. The tool PageDefrag could defragment Windows system files such as the swap file and the files that store the Windows registry by running at boot time before the GUI is loaded. Since Windows Vista, the feature is not fully supported and has not been updated.

If the NTFS Master File Table (MFT) must grow after the partition was formatted, it may become fragmented, and in early versions of Windows it could not be safely defragmented while the partition was in use. An increasing number of defragmentation programs are able to defragment the MFT in versions of Windows since XP with API support for this.[2]

User and performance issues

In a wide range of modern multi-user operating systems, an ordinary user cannot defragment the system disks since superuser (or "Administrator") access is required to move system files. Additionally, file systems such as NTFS are designed to decrease the likelihood of fragmentation.[3][4] Improvements in modern hard drives such as RAM cache, faster platter rotation speed, command queuing (SCSI TCQ/SATA NCQ), and greater data density reduce the negative impact of fragmentation on system performance to some degree, though increases in commonly used data quantities offset those benefits. However, modern systems profit enormously from the huge disk capacities currently available, since partially filled disks fragment much less than full disks,[5] and on a high-capacity HDD, the same partition occupies a smaller range of cylinders, resulting in faster seeks. However, the average access time can never be lower than a half rotation of the platters, and platter rotation (measured in rpm) is the speed characteristic of HDDs which has experienced the slowest growth over the decades (compared to data transfer rate and seek time), so minimizing the number of seeks remains beneficial in most storage-heavy applications. Defragmentation is just that: ensuring that there is at most one seek per file, counting only the seeks to non-adjacent tracks.

When reading data from a conventional electromechanical hard disk drive, the disk controller must first position the head, relatively slowly, to the track where a given fragment resides, and then wait while the disk platter rotates until the fragment reaches the head.

Since disks based on flash memory have no moving parts, random access of a fragment does not suffer this delay, making defragmentation to optimize access speed unnecessary. Furthermore, since flash memory can be written to only a limited number of times before it fails, defragmentation is actually detrimental.

Windows System Restore points may be deleted during defragmenting/optimizing

Running most defragmenters and optimizers can cause the Microsoft Shadow Copy service to delete some of the oldest restore points, even if the defragmenters/optimizers are built on Windows API. This is due to Shadow Copy keeping track of some movements of big files performed by the defragmenters/optimizers; when the total disk space used by shadow copies would exceed a specified threshold, older restore points are deleted until the limit is not exceeded.[6]

Defragmenting and optimizing

Besides defragmenting program files, the defragmenting tool can also reduce the time it takes to load programs and open files. For example, the Windows 9x defragmenter included the Intel Application Launch Accelerator which optimized programs on the disk.[7] The outer tracks of a hard disk have a higher transfer rate than the inner tracks, therefore placing files on the outer tracks increases performance.[8] In addition, the defragmenting tool may also use free space on other partitions or drives to be able to defragment volumes of low disk space.

Approach and defragmenters by file-system type

  • FAT: MS-DOS 6.x and Windows 9x-systems come with a defragmentation utility called Defrag. The DOS version is a limited version of Norton SpeedDisk.[9] The version that came with Windows 9x was licensed from Symantec Corporation, and the version that came with Windows 2000 and above (with the exceptions of Vista, Server 2008, and 7) is licensed from Diskeeper Corporation.
  • NTFS: Windows 2000-2003 include a defragmentation tool based on Diskeeper.[10] Newer versions of Windows ship with a Microsoft product. Windows NT 4.0 includes an application programming interface that third-party tools can use to perform defragmentation tasks, but no command-line or graphical tools are included that make use of it. Windows NT 3.51 and below do not include any defragmentation capabilities. A number of free and commercial third-party defragmentation products are available for Microsoft Windows.
  • BSD UFS and particularly FreeBSD uses an internal reallocator that seeks to reduce fragmentation right in the moment when the information is written to disk. This effectively controls system degradation after extended use.
  • ext2, ext3, and ext4 (Linux): ext2 uses an offline defragmenter called e2defrag, which does not work with its successor ext3. However, other programs, or filesystem-independent ones, may be used to defragment an ext3 filesystem. ext4 is somewhat backward compatible with ext3, and thus has generally the same amount of support from defragmentation programs.
  • VxFS has the fsadm utility meant to perform also defrag operations.
  • JFS has the defragfs utility on IBM operating systems.[11]
  • HFS Plus (Mac OS X) introduced in 1998 a number of optimizations to the allocation algorithms in an attempt to defragment files while they are being accessed without a separate defragmenter. If the filesystem becomes fragmented, the only way to defragment it is to use a utility such as Coriolis System's iDefrag, or to wipe the hard drive completely and install the system from scratch.
  • WAFL in NetApp's ONTAP 7.2 operating system has a command called reallocate that is designed to defragment large files.
  • XFS provides an online defragmentation utility called xfs_fsr.
  • SFS processes the defragmentation feature in almost completely stateless way (apart from the location it is working on), so defragmentation can be stopped and started instantly.

See also


  1. ^ The practice of marking the now unused space of a deleted file in a table as available for later use without erasing its contents, and reusing the space only when needed, is why undelete programs were able to work; they recovered files whose names had been deleted from the directory, so long as their space had not yet been reused.
  2. ^ [1] "The other big enhancement [in windows XP] is support for online defragmentation of the MFT and most directory and file metadata"
  3. ^ Serdar Yegulalp (18 September 2006). "Disk defragmentation: Performance-sapping bogeyman, or best practice?". Disk Defragmentation Fast Guide.,289483,sid68_gci1215568,00.html. Retrieved 2008-12-27. "One of the many improvements NTFS provided was a reduced propensity for fragmentation." 
  4. ^ Darcy, Jeff (19 April 2002). "Filesystem Fragmentation". Canned Platypus. "UNIX filesystems tend to do a lot to prevent fragmentation and generally reduce head motion - preallocation, cylinder groups, blah blah blah - but it does still occur and most filesystems don’t actually do all that much to undo it once it exists." 
  5. ^ Serdar Yegulalp (20 September 2005). "New hard disk drives reduce need for disk defragmentation". Disk Defragmentation Fast Guide.,289483,sid68_gci1216336,00.html. Retrieved 2008-12-27. 
  6. ^ Jeroen Kessels (21 May 2010). "FAQ Using - Why do I have more diskspace after running MyDefrag?". Retrieved 2010-10-11. 
  7. ^
  8. ^
  9. ^ Norton, Peter (October 1994). Peter Norton's Complete Guide to DOS 6.22. Sams. p. 521. 
  10. ^
  11. ^ "Journaling File System Support". eComStation. Retrieved 2008-12-27. 


  • Norton, Peter (1994) Peter Norton's Complete Guide to DOS 6.22, page 521 - Sams (ISBN 067230614X)
  • Woody Leonhard, Justin Leonhard (2005) Windows XP Timesaving Techniques For Dummies, Second Edition page 456 - For Dummies (ISBN 0-764578-839).
  • Jensen, Craig (1994). Fragmentation: The Condition, the Cause, the Cure. Executive Software International (ISBN 0-9640049-0-9).
  • Dave Kleiman, Laura Hunter, Mahesh Satyanarayana, Kimon Andreou, Nancy G Altholz, Lawrence Abrams, Darren Windham, Tony Bradley and Brian Barber (2006) Winternals: Defragmentation, Recovery, and Administration Field Guide - Syngress (ISBN 1-597490-792)
  • Robb, Drew (2003) Server Disk Management in a Windows Environment Chapter 7 - AUERBACH (ISBN 0849324327)

External links

Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Defragmentation — Défragmentation Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom. La notion de défragmentation peut avoir plusieurs sens, dont : la défragmentation, en informatique :consiste à regrouper les… …   Wikipédia en Français

  • Défragmentation — Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom. La notion de défragmentation peut avoir plusieurs sens, dont : la défragmentation, en informatique : consiste à regrouper les fragments de… …   Wikipédia en Français

  • defragmentation —    The process of reorganizing and rewriting files so that they occupy one large area on a hard disk rather than several smaller areas.    When a file on a hard disk is updated, it may be written into different areas all over the disk. This… …   Dictionary of networking

  • defragmentation — defragmentavimas statusas T sritis informatika apibrėžtis Failų perskirstymas diske taip, kad jie užimtų vientisas sritis, nesuskaidytas į fragmentus. Pradžioje vieta diske failams skiriama tvarkingai, jie rašomi iš eilės į vientisą sritį.… …   Enciklopedinis kompiuterijos žodynas

  • defragmentation — noun see defragment …   New Collegiate Dictionary

  • defragmentation — See defragment. * * * …   Universalium

  • defragmentation — noun The action of defragmenting, particularly with respect to a computer disk or drive. See Also: fragmentation …   Wiktionary

  • défragmentation — ● n. f. ►GESTFICH Action consistant à défragmenter les fichiers d un disque ou d une partition, c est à dire à réunir les secteurs les constituant pour qu ils soient consécutifs sur le disque …   Dictionnaire d'informatique francophone

  • defragmentation — n. reunite files, splice together a file that is scattered across the surface of a disk (Computers) …   English contemporary dictionary

  • defragmentation — de·fragmentation …   English syllables

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”

We are using cookies for the best presentation of our site. Continuing to use this site, you agree with this.