Defragmenting XFS file systems in Fedora 23

If you thought that only the only NTFS and Fat systems were fragmented, then surely you will be surprised when reading these lines, and it is very common to think that this only happens with Windows, but in reality all file systems to a lesser or greater extent It will end up fragmenting, whenever new information is erased and written, “gaps” are created that will be filled with certain data that are of different sizes from each other, this being what produces fragmentation.

Certainly each file system has certain characteristics when it comes to dealing with fragmentation, my favorite is XFS not only because of its support with Red Hat, but in addition to this it is one of the best for larger partitions and that takes better advantage of 64-bit processors.

RH_Fedora_logo_web

So let's start by checking the fragmentation status of the hard drive.

For this we will use a tool for XFS called xfs_db with this we can debug XFS eXtendedFileSistem_DeBuger In most cases this tool comes with the system if you use XFS, if not, we must install xfsdump.

Let's find out if we have xfsdump in Fedora 23

dnf search xfs

Last metadata expiration check performed —-.

================================================ ========================== S / N Matched: xfs =================== ================================================= ======


xfsdump.armv7hl: Administrative utilities for the XFS filesystem


xfsdump is the utility package that Fedora provides, in the case of Arch it is already integrated into the system.

images (1)

To check the fragmentation status of an xfs partition, we will write this code:

xfs_db -c frag -r / dev /

The recommendation is that if it is greater than 10% proceed to defragment, if it is less then you can leave it for later.

Now, if we use "-c frag" the command that we are going to execute is sent to xfs_db just to consult, if we do not place the "-c frag" then it will place a promp so that we can execute queries and we will put "frag" on it, the fastest way would be:

xfs_db -c frag -r / dev / mmcblk0p3 actual 66155, ideal 65615, fragmentation factor 0.82%

As we see in the previous part, I have a degree of fragmentation of 0.82% since a few days ago I defragmented it, it was about 5% fragmentation.

images

Defragmenting the XFS partition

Now we proceed to defragment the partition, to begin we must execute xfs_fsr what is inside the package xfsdump that we installed previously; xfs_fsr means eXtendedFileSystem_FileSystemReorganizer, and your task is that, reorganize the XFS system.

So we write:

xfs_fsr -v / dev / mmcblk0p3 / start inode = 0ino = 1928extents before: 2 after: 1 DONE ino = 1928ino = 219417extents before: 2 after: 1 DONE ino = 219417ino = 219395—

Taking into account that depending on the degree of fragmentation, the time it takes to perform the defragmentation will be greater or lesser.

Once the process is finished, we review the degree of fragmentation again:

xfs_db -c frag -r / dev / mmcblk0p3

Defragmentation

And this is the way to defragment XFS systems, if you have hard drives with Terabytes partitions and when reviewing the degree of fragmentation and it reaches 10%, after defragmenting you can see the difference.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Ishmael_TEch said

    excellent information !! thanks!! I was looking for this precisely and I found it here, keep up the good work !!

    Regards…

  2.   merlinoelodebianite said

    And in debian how is it done, are they the same lines?

  3.   gabo said

    I would only add for the unwary that only file systems on hard drives should be defragmented. While defragmenting isn't going to kill a solid state drive, it does cause it to "wear out" prematurely.

    regards
    Nicolas Gabbo

  4.   waKeMaTTa said

    Could I make another one for Ubuntu?

    1.    eliotime3000 said

      I'd like you to make one for Debian too.