How to Repair and Defragment Linux System Pa... about:reader?url=https://www.tecmint.com/def...
tecmint.com
How to Repair and Defragment
Linux System Partitions and
Directories
5-7 minutes
People who use Linux often think that it doesn’t require
defragmentation. This is a common misunderstanding
across Linux users. Actually, the Linux operating system
does support defragmentation. The point of the
defragmentation is to improve I/O operations like allowing
local videos to load faster or extracting archives significantly
faster.
Defragment Linux System Partitions and Directories
The Linux ext2, ext3 and ext4 filesystems don’t need that
much attention, but with time, after executing many many
many read/writes the filesystem may require optimization.
1 of 6 07/06/22, 12:22 am
How to Repair and Defragment Linux System Pa... about:reader?url=https://www.tecmint.com/def...
Otherwise the hard disk might become slower and may
affect the entire system.
In this tutorial I am going to show you few different
techniques to perform defragmentation on files. Before we
start, we should mention what the common filesystems like
ext2,3,4 do to prevent fragmentation. These filesystems
include technique to prevent the effect. For example
filesystems reserve free block groups on the hard disk to
store growing files completely.
Unfortunately the problem is not always solved with such
mechanism. While other operating systems may require
expensive additional software to resolve such issues, Linux
has some easy to install tools that can help you resolve
such problems.
How to Check a Filesystem Requires Defragmentation?
Before we start I would like to point that the operations
below should only be ran on HDDs and not on
SSD. Defragging your SSD drive will only increase its
read/write count and therefore shorten it’s life. Instead, if
you are using SSD, you should use the TRIM function,
which is not covered in this tutorial.
let’s test if the system actually requires defragmentation. We
can easily check this with tool such as e2fsck. Before you
use this tool on a partition on your system, it is
recommended to unmount that partition with. This is not
completely necessary, but it’s the safe way to go:
$ sudo umount <device file>
2 of 6 07/06/22, 12:22 am