We will show you the two method using different tools to Defragment A Hard Drive In Ubuntu And It’s Derivatives.
Tutorial To Defragment A Hard Drive In Ubuntu And It’s Derivatives
At first let’s defrag hard drive using FSCK in Ubuntu:
“Fsck” stands for “File System Consistency check”. It is always better and safe to run this command from a live cd and also if you used fsck command on a mounted partition, there is a high chance that it will damage the filesystem.
Meanwhile, if you want to run in from your installed Ubuntu then the command is:
fsck -fn /dev/sda2
If you want to check Home folder which is on another another partition, Use the following commands:
Auto repair the filesystem:
To exclude mounted partition from the scan:
You can use GUI base Gparted if you are having trouble to use the command line interface to check and repair.
sudo apt-get install gparted
Defrag using e4defrag tool in Ubuntu:
You need to install it first and to do so:
sudo apt-get install e2fsprogs
sudo e4defrag “path”
Run the defragment process without unmounting:
sudo e4defrag /
Run the defragment process by mounting
sudo e4defrag /dev/*
Drop the comment below if you find any error or confusion in this article.