# Defragmentation

Defragmentation is the process of reorganizing the fragmented data on a hard drive so that files are stored in contiguous blocks rather than being scattered across the disk. When data is fragmented, the system has to access different parts of the disk to read a single file, which can slow down performance, particularly on traditional hard disk drives (HDDs).

***

## How Defragmentation Works:

1. **Reorganizing Files**: Defragmentation moves the fragments of each file to be stored together in a continuous block on the disk. This reduces the number of times the disk has to seek different areas to access a file, improving read times.
2. **Consolidating Free Space**: Defragmentation also groups free space into larger contiguous blocks. This prevents future files from becoming fragmented when they are saved or modified.

***

Remember the movies that you downloaded before? After applying a defragmentation process this is how they would be stored on the disk.

<figure><img src="https://2490252025-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUwIKQPujWqWSVFxQaX98%2Fuploads%2FNqriqJ5mR6NFj5ofSrNi%2Flong%20movie%20ond%20diks.png?alt=media&#x26;token=e49d6476-1a8e-403b-8f5f-4f04fce7e54d" alt="" width="553"><figcaption></figcaption></figure>

The green and the blue would swap places, and the whole thing would look a lot cleaner.

{% hint style="info" %}
Tip If your disk had a fragmntation more than 10%, you should defragment it.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bata-mladen.gitbook.io/bata-mladen/notes/computer-concepts/file-systems/defragmentation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
