Defrag linux manjaro

Is it possible to defrag-my linux manjaro and is there a program to use to clean up unused files and create some free space.

Also how do i access my hard drive >

Defraging is a Windows thing

pacui is a program that has a maintenance section as well:

Use your file manager.


Not all filesystems need defragmentation. What is yours?

Here are some tips for cleaning your system.

The most common tool to access the content of your drive is your file manager.


Thanks for all your help ?

You put that as a question intentionally?

If you filesystem is ext4 - the most common Linux file system - I don’t know about the other - you can use e4defrag. The common fsck utility can do it too - for either to work reliably you will have to boot from USB as you cannot fsck a mounted device.

Do not defrag SSD devices. If you device is SSD - use the fstrim instead - but not too often. There is a timer which will schedule fstrim once ever two weeks.

sudo systemctl enable --now fstrim.timer

or manually

sudo fstrim -a

Defragmentation in most cases is unnecessary. There are tools for windows who try to impress the user by saying:

  • I did a defrag of your harddisk. This was soooooo necessary. If you like you can watch how i do this graphically :wink:
  • I did find some unused files you will not miss. I wan’t to delete them to free space, so your PC will have more room now. This is the BIG ammount i found
  • You have some bad programs on your pc. I will protect you from harm
  • I could do more, but therefore you must buy the professional version

These where lies 20 years ago (snake-oil). Today there has nothing changed.

  • The PC does not get faster
  • Your Harddisk will not get bigger
  • Nobody can protect you when you are careless

When you get manjaro and you learn to use it. You don’t need no programs from such liars.


ext4 doesn’t need defrag much. You can however defrag it with e4drag command once every 6 month or once in a year.

Too add to what @linux-aarhus wrote above:

You might prefer the “verbose” option to see the results:
sudo fstrim -va

I thought it was once per week, but I could be wrong or it might have changed?

:+1: :point_up_2: Using Ext4, XFS, or Btrfs? Probably don’t need to (nor want to) defrag. And it’s even more true with SSD.

The reason Windows requires defragmenting is due to how FAT32 and NTFS writes new data. It just stupidly writes to the next available free space, and continues sequentially, jumping over existing data if the file/data is to large to “lay down” as a single contiguous piece. This also means that as you delete, modify, write, delete, modify, write and so forth throughout your daily usage, the filesystem becomes more and more fragmented.

However, with Linux using Ext4 and XFS (which I’m sure applies to Btrfs as well), it intelligently writes the new data to areas of the block device with enough contiguous space to accommodate it. It doesn’t just simply dump the data in the next available block, like Windows does.

Let’s say this is what the layout looks like on your filesystem.

( _ is “free space”, U is “currently used”, ^ is “new write” )


NTFS or FAT32 will write the new data like so, assuming it’s a large file:


Whereas Ext4 and XFS are likely to write the new data like so:


Over time, the NTFS or FAT32 filesystem will become very fragmented, while the Ext4 or XFS filesystem will contain much less fragmentation in comparison. In fact, just using your filesystem like normal will continue to err towards contiguous data and low fragmentation. I’ve heard a “rule of thumb” is this design works great as long as you keep your usage under 80% capacity.