For nearly as long as computer storage has existed, disk fragmentation and RAM fragmentation have been concerns. Fragmentation is not always bad, as it serves a specific purpose in how some operating system work. However, it can also be an impediment to overall storage efficiency.
In this Enterprise Storage Forum article we define fragmentation and explain what disk fragmentation is about, including internal fragmentation, external fragmentation and file fragmentation.
What is Fragmentation?
Disk fragmentation at the most basic level is about fragmented data on a storage device. The fragmentation is a result of discontinuous application or file system storage, where different parts of a given application or file are not stored in a sequential set of storage blocks on a storage device.
In short, proximity matters. An operating system will typically store application and file storage blocks in the next available location on a storage device. This might not necessarily be the storage block that is directly adjacent to the prior block in an application.
Disk fragmentation typically increases over time as read and write operations take place within an operating system. Applications and files are added and removed, so new storage leaves different blocks open in a non-contiguous manner.
Fragmentation is sometimes regarded as being an inefficient use of file storage resources: disk read times are increased as the various locations where a given file of applications need to be found and accessed. On the other hand, the ability of an operating system to rapidly write files on any available storage block, without first re-allocating blocks so there is a sequential read, speeds up file writing operations.
Fragmentation also occurs in system memory (RAM). Application and system processes allocate and use memory in non-contiguous blocks, as existing memory registers are used and re-used.
A fragmented disk holds related data in non-contiguous locations, in contrast to a more logically allocated defragmented disk.
What is the Purpose of Fragmentation?
The purpose of fragmentation is to help an operating system use the available space on a storage device.
In the absence of disk fragmentation, application and file storage need to continuously be updating and moving storage blocks, in order to maintain a continuous, non-fragmented file system. Disk fragmentation is viewed as a necessary byproduct of enabling an operating system to write storage bits as quickly as possible.
Types of Fragmentation
Fragmentation occurs whenever an operating system or application writes a file that is not directly contiguous with the preceding storage bit. By definition, disk and file fragmentation is all about storage that is allocated in fragments and not in sequential order.
There are several key types of fragmentation:
- Internal Fragmentation. Refers to a type of fragmentation where either RAM system memory or storage space is over provisioned and then not used by the operating system or application.
- External Fragmentation. Occurs when an application or process is removed from memory or from a storage system and the used space is not immediately reallocated, leaving a fragment.
- Data Fragmentation. With data fragmentation, data is written to memory or file storage in a non-sequential manner, using the next available storage block.
Internal vs. External Fragmentation
|Internal Fragmentation||External Fragmentation|
|Why It Happens||Internal fragmentation happens because memory and storage is typically partitioned into fixed-sized units.||External fragmentation is a function of memory being partitioned into variable-sized blocks that are dynamically allocated by different processes.|
|The Result||When space is allocated that doesn’t completely fill a fixed-size unit, a leftover fragment remains.||As space is used and then released, a fragment can be left behind.|
|How to Resolve||Use dynamic allocation tools within the operating system.||Use defragmentation tools.|
Advantages of Fragmentation
- Fewer failures. In a system that doesn’t enable fragmentation, if there isn’t enough sequential space, the write will fail.
- Faster data writes. Rather than trying to reorganize data storage to enable contiguous data write, in a system that supports data fragmentation, data writes can often be faster.
- Storage optimization. By making use of every available storage block, a fragmented system can potentially make more use of a storage device.
Disadvantages of Fragmentation
- Slower read times. As a storage device become increasingly fragmented, the amount of time it takes to read a non-sequential file can grow.
- Need for regular defragmentation. Over time, an increasingly fragmented storage device will have degraded performance, necessitating the need for regular defragmentation routines, which are often time consuming.