How to Stop Ubuntu from Automatically Defragmenting Disks

The Wear and Tear

Historically, on older mechanical hard drives (HDDs), files would become fragmented, slowing down read/write speeds. Operating systems would run defragmentation tools to reorganize the data. Modern Ubuntu systems utilize the ext4 file system, which is incredibly efficient at preventing fragmentation in the first place. Furthermore, if you are running Ubuntu on a modern Solid State Drive (SSD)—which almost all computers use today—defragmentation is entirely unnecessary and actually harmful. SSDs have a limited number of write cycles; automatically running an e4defrag script via a cron job will needlessly churn data, degrading the lifespan of your SSD without providing any performance benefit.

Checking for Rogue Scripts

To protect your SSD hardware and ensure Ubuntu is not automatically defragmenting your disks in the background, you must verify that no legacy cron jobs are active.

By default, a fresh installation of Ubuntu does not auto-defragment. However, if you upgraded from a very old system or blindly ran a “speed up Linux” script from the internet, a cron job might have been created. Open your terminal (Ctrl+Alt+T). You need to check the system-wide daily cron directory. Type ls -l /etc/cron.daily/ and press Enter. Look through the list of files outputted to the terminal. If you see a file named something like e4defrag or defrag-disk, you must remove it or disable it. To safely disable it without deleting it, you can remove its executable permission by typing sudo chmod -x /etc/cron.daily/e4defrag (replace ‘e4defrag’ with the actual filename if it differs). The system will no longer run it automatically.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.