Hubbry Logo
search
logo
1629675

File system fragmentation

logo
Community Hub0 Subscribers
Write something...
Be the first to start a discussion here.
Be the first to start a discussion here.
See all
File system fragmentation

File system fragmentation, sometimes called file system aging, is a characteristic of a file system that stores files in non-contiguous blocks. It is a special case of data fragmentation. File system fragmentation negatively impacts seek time for disk storage (spinning storage medium), which lowers throughput. Fragmentation can be eliminated by re-organizing files as contiguous areas, a process called defragmentation.

A solid-state drive (SSD) does not mechanically seek, so non-sequential access is orders of magnitude faster than disk drives, making fragmentation significantly less of an issue. In fact, best practice is to not defragment an SSD, because doing so can prematurely wear drives via unnecessary write and erase operations.

When a file system is first initialized on a partition, it contains only a few small internal structures and is otherwise one contiguous block of empty space. This means that the file system is able to place newly created files anywhere on the partition. For some time after creation, files can be laid out near-optimally. When the operating system and applications are installed or archives are unpacked, separate files end up occurring sequentially so related files are positioned close to each other.

As existing files are deleted or truncated, new regions of free space are created. When existing files are appended to, it is often impossible to resume the write exactly where the file used to end, as another file may already be allocated there; thus, a new fragment has to be allocated. As time goes on, and the same factors are continuously present, free space as well as frequently appended files tend to fragment more. Shorter regions of free space also mean that the file system is no longer able to allocate new files contiguously, and has to break them into fragments. This is especially true when the file system becomes full and large contiguous regions of free space are unavailable.

The following example is a simplification of an otherwise complicated subject. Consider the following scenario: A new disk has had five files, named A, B, C, D and E, saved continuously and sequentially in that order. Each file is using 10 blocks of space. (Here, the block size is unimportant.) The remainder of the disk space is one free block. Thus, additional files can be created and saved after the file E.

If the file B is deleted, a second region of ten blocks of free space is created, and the disk becomes fragmented. The empty space is simply left there, marked as and available for later use, then used again as needed. The file system could defragment the disk immediately after a deletion, but doing so would incur a severe performance penalty at unpredictable times.

Now, a new file called F, which requires seven blocks of space, can be placed into the first seven blocks of the newly freed space formerly holding the file B, and the three blocks following it will remain available. If another new file called G, which needs only three blocks, is added, it could then occupy the space after F and before C.

If subsequently F needs to be expanded, since the space immediately following it is occupied, there are three options for the file system:

See all
User Avatar
No comments yet.