In this guide, we are going to learn how to maintain the integrity of Linux filesytems. In modern Linux,  every operation is registered in an internal log (the journal) before it is executed. This means that the filesystems are journaled. If the operation is interrupted due to a system error (like a kernel panic, power failure, etc.) it can be reconstructed by checking the journal, avoiding filesystem corruption and loss of data. Being familiar with the tools used for this tasks can reduce the need for manual filesystem check.

Maintaining ext2, ext3 and ext4 Filesystems

fsck utility “filesystem check” is used to check a filesystem for errors and hopefully fix them.  You can invoke it with fsck followed by the filesystem’s location you want to check i.e

$ sudo fsck /dev/sda3
fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
/dev/sda3: clean, 1536/5316608 files, 19248152/21241088 blocks

When the filesystem is not specified, fsck assumed an ext2/3/4 filesystem by default, and called e2fsck. To specify a filesystem, use the -t option, followed by the filesystem name i.e;

$ sudo fsck -t vfat /dev/sdb

fsck Command-line Arguments

The most common fsck arguments are;

  • -A: This will check all filesystems listed in /etc/fstab.
  • -C: Displays a progress bar when checking a filesystem. Currently only works on ext2/3/4 filesystems.
  • -N: This will print what would be done and exit, without actually checking the filesystem.
  • -R: When used in conjunction with -A, this will skip checking the root filesystem.
  • -V: Verbose mode, prints more information than usual during operation. This is useful for debugging.

e2fsck Non-interactive Mode Options

The specific utility for ext2, ext3 and ext4 filesystems is e2fsck, also called fsck.ext2fsck.ext3 and fsck.ext4 (those three are merely links to e2fsck). By default, it runs in interactive mode: when a filesystem error is found, it stops and asks the user what to do. The user must type y to fix the problem, n to leave it unfixed or a to fix the current problem and all subsequent ones.

  • -p: This will attempt to automatically fix any errors found. If an error that requires intervention from the system administrator is found, e2fsck will provide a description of the problem and exit.
  • -y: This will answer y (yes) to all questions.
  • -n: The opposite of -y. Besides answering n (no) to all questions, this will cause the filesystem to be mounted read-only, so it cannot be modified.
  • -f: Forces e2fsck to check a filesystem even if is marked as “clean”, i.e. has been correctly unmounted.

NOTE: NEVER run fsck (or related utilities) on a mounted filesystem. If this is done anyway, data may be lost.

Fine Tuning an ext Filesystem

System Admistrators can adjust or tune ext2, ext3 and ext4 filesystems parameters to better suit the system needs. The utility used to display or modify these parameters is called tune2fs.

use the -l parameter followed by the device representing the partition in order to see the current parameters for any given filesystem. i.e /dev/sda3;

$ sudo tune2fs -l /dev/sda3
[sudo] password for frank: 
tune2fs 1.45.5 (07-Jan-2020)
Filesystem volume name:   <none>
Last mounted on:          /media/frank/e3ef9af4-7136-4650-8365-c6c02d0d14f4
Filesystem UUID:          e3ef9af4-7136-4650-8365-c6c02d0d14f4
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              5316608
Block count:              21241088
Reserved block count:     1062054
Free blocks:              1992936
Free inodes:              5315072
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      1018
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Fri Oct 30 09:05:46 2020
Last mount time:          Thu May 13 16:34:46 2021
Last write time:          Sat May 15 16:53:59 2021
Mount count:              92
Maximum mount count:      -1
Last checked:             Fri Oct 30 09:05:46 2020
Check interval:           0 (<none>)
Lifetime writes:          96 GB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:	          256
Required extra isize:     32
Desired extra isize:      32
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      599589c7-d958-4e39-a850-bacbacfdcbeb
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0xbf7dfdff

ext filesystems have mount counts. The count is increased by 1 each time the filesystem is mounted, and when a threshold value (the maximum mount count) is reached the system will be automatically checked with e2fsck on the next boot.

  • -c N parameter: Is use to set the maximum mount count. where N is the number of times the filesystem can be mounted without being checked.
  • -C N parameter: Is used to sets the number of times the system has been mounted to the value of N.
  • -i parameter: Is used to define a time interval between checks. -i parameter, followed by a number and the letters d for days, m for months and y for years. For example, -i 20d would check the filesystem at the next reboot every 20 days. Use zero as the value to disable this feature.
  • -L parameter: Can be used to set a label for the filesystem. This label can have up to 16 characters.
  • -U parameter: Is used to sets the UUID for the filesystem, which is a 128 bit hexadecimal number. In the example above, the UUID is e3ef9af4-7136-4650-8365-c6c02d0d14f4. Both the label and UUID can be used instead of the device name (like /dev/sda3) to mount the filesystem.

The option -e BEHAVIOUR defines the kernel behaviour when a filesystem error is found. There are three possible behaviours:

  • continue: Will continue execution normally.
  • remount-ro: Will remount the filesystem as read-only.
  • panic: Will cause a kernel panic.

The default behaviour is to continueremount-ro might be useful in data-sensitive applications, as it will immediately stop writes to the disk, avoiding more potential errors.

Using tune2fs you can add a journal to an ext2 filesystem, thus converting it to ext3. ext3 filesystems are basically ext2 filesystems with a journal i.e. -j parameter is used with tune2fs, followed by the device containing the filesystem:

$ sudo tune2fs -j /dev/sda3

when mounting the converted filesystem, do not forget to set the type to ext3 so the journal can be used.

When dealing with journaled filesystems, the -J parameter allows you to use extra parameters to set some journal options:

  • -J size= to set the journal size (in megabytes).
  • -J location= to specify where the journal should be stored (either a specific block, or a specific position on the disk with suffixes like M or G). 
  • -J device= to put the journal on an external device.


$ sudo tune2fs -J size=30,location=300M,device=/dev/sdb3

The above command will create a 30 MB Journal at the 300 MB position on the device /dev/sdb3.

Monitoring Free Space and Inodes

Checking Disk Usage with du Command

dudisk usage” command displays disk usage by directory and it’s good for finding users or applications that are taking up the most disk space. du command simply show how many 1 Kilobyte blocks are being used by the current directory and all its subdirectories i.e.

$ du
4	./dejavu-fonts-ttf-2.37/ttf
28	./dejavu-fonts-ttf-2.37/fontconfig
1704	./dejavu-fonts-ttf-2.37
2516	./fontawesome-free-5.14.0-web/webfonts
268	./fontawesome-free-5.14.0-web/less
3552	./fontawesome-free-5.14.0-web/metadata
4860	./fontawesome-free-5.14.0-web/js
612	./fontawesome-free-5.14.0-web/svgs/regular
4036	./fontawesome-free-5.14.0-web/svgs/solid
1864	./fontawesome-free-5.14.0-web/svgs/brands
6516	./fontawesome-free-5.14.0-web/svgs
284	./fontawesome-free-5.14.0-web/scss
380	./fontawesome-free-5.14.0-web/css
1204	./fontawesome-free-5.14.0-web/sprites
19588	./fontawesome-free-5.14.0-web
31792	.

Using -h parameter will print sizes in human readable format (e.g., 1K 234M 2G).

$ du -h
4.0K	./dejavu-fonts-ttf-2.37/ttf
28K	./dejavu-fonts-ttf-2.37/fontconfig
1.7M	./dejavu-fonts-ttf-2.37
2.5M	./fontawesome-free-5.14.0-web/webfonts
268K	./fontawesome-free-5.14.0-web/less
3.5M	./fontawesome-free-5.14.0-web/metadata
4.8M	./fontawesome-free-5.14.0-web/js
612K	./fontawesome-free-5.14.0-web/svgs/regular
4.0M	./fontawesome-free-5.14.0-web/svgs/solid
1.9M	./fontawesome-free-5.14.0-web/svgs/brands
6.4M	./fontawesome-free-5.14.0-web/svgs
284K	./fontawesome-free-5.14.0-web/scss
380K	./fontawesome-free-5.14.0-web/css
1.2M	./fontawesome-free-5.14.0-web/sprites
20M	./fontawesome-free-5.14.0-web
32M	.

du only shows the usage count for directories by default, -a parameter shows an individual count for all files in the directory;

$ du -ah
9.7M	./25 Days of Christmas Writeup (Blurred).pdf
38M	./MyFiles/vagrant_2.2.14_x86_64.deb
0	./MyFiles/listings.txt
38M	./MyFiles
256K	./presentation.ppt
38M	./vagrant_2.2.14_x86_64.deb
0	./listings.txt
150M	./
150M	./myfile.cpio
256K	./presentation (2).ppt
75M	./google-chrome-stable_current_amd64.deb
24K	./presentation.docx
14M	./LPIC-1 Linux Professional Institute Certification Study Guide [].pdf
473M	.

— exclude parameter will exclude files that match PATTERN. For example in the above output we can exclude .pdf extension;

$ du -ah --exclude="*.pdf"
38M	./MyFiles/vagrant_2.2.14_x86_64.deb
0	./MyFiles/listings.txt
38M	./MyFiles
256K	./presentation.ppt
38M	./vagrant_2.2.14_x86_64.deb
4.0K	./dir1/sudo
0	./dir1/AboutLinux.txt
0	./dir1/Linux.txt
8.0K	./dir1
0	./listings.txt
150M	./
150M	./myfile.cpio
256K	./presentation (2).ppt
75M	./google-chrome-stable_current_amd64.deb
24K	./presentation.docx
449M	.

Using -S parameter for directories do not include size of subdirectories;

$ du -hS
38M	./MyFiles
435M	.

-c parameter produce a grand total;

$ du -hSc
38M	./MyFiles
435M	.
473M	total

You can control how “deep” the output of du should go with the -d N parameter,

where N describes the levels. For example, if you use the -d 1 parameter, it will show the current directory and its subdirectories, but not the subdirectories of those.

See the difference below. Without -d;

$ du -h
38M	./MyFiles
4.0K	./dir1/sudo
8.0K	./dir1
473M	.

And limiting the depth to one level with -d 1;

$ du -h -d1
38M	./MyFiles
8.0K	./dir1
473M	.

Checking for Free Space with df command

df command displays disk usage by partition. df command will provide a list of all of the available (already mounted) filesystems on your system, including their total size, how much space has been used, how much space is available, the usage percentage and where it is mounted;

$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
udev             3994496         0   3994496   0% /dev
tmpfs             804992      1596    803396   1% /run
/dev/sda2      180876872 115764240  55854856  68% /
tmpfs            4024948     27864   3997084   1% /dev/shm
tmpfs               5120         4      5116   1% /run/lock
tmpfs            4024948         0   4024948   0% /sys/fs/cgroup
/dev/loop0        212096    212096         0 100% /snap/code/64
/dev/loop1        212096    212096         0 100% /snap/code/65
/dev/loop2        101632    101632         0 100% /snap/core/10958
/dev/loop3        101376    101376         0 100% /snap/core/11081
/dev/loop4         56832     56832         0 100% /snap/core18/1988
/dev/loop5         56832     56832         0 100% /snap/core18/1997
/dev/loop6        223232    223232         0 100% /snap/gnome-3-34-1804/60
/dev/loop7        224256    224256         0 100% /snap/gnome-3-34-1804/66
/dev/loop9         66432     66432         0 100% /snap/gtk-common-themes/1514
/dev/loop10        52352     52352         0 100% /snap/snap-store/498
/dev/loop8         66688     66688         0 100% /snap/gtk-common-themes/1515
/dev/loop11        52352     52352         0 100% /snap/snap-store/518
tmpfs             804988        20    804968   1% /run/user/1000
/dev/sda3       83105328  75133584   3707144  96% /media/frank/e3ef9af4-7136-4650-8365-c6c02d0d14f4
/dev/sda1      218593248  53836172 164757076  25% /media/frank/01D5FAEEFC8E1CB0

Using -h parameters will display the output “human readable” format;

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           787M  1.6M  785M   1% /run
/dev/sda2       173G  111G   54G  68% /
tmpfs           3.9G   28M  3.9G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0      208M  208M     0 100% /snap/code/64
/dev/loop1      208M  208M     0 100% /snap/code/65
/dev/loop2      100M  100M     0 100% /snap/core/10958
/dev/loop3       99M   99M     0 100% /snap/core/11081
/dev/loop4       56M   56M     0 100% /snap/core18/1988
/dev/loop5       56M   56M     0 100% /snap/core18/1997
/dev/loop6      218M  218M     0 100% /snap/gnome-3-34-1804/60
/dev/loop7      219M  219M     0 100% /snap/gnome-3-34-1804/66
/dev/loop9       65M   65M     0 100% /snap/gtk-common-themes/1514
/dev/loop10      52M   52M     0 100% /snap/snap-store/498
/dev/loop8       66M   66M     0 100% /snap/gtk-common-themes/1515
/dev/loop11      52M   52M     0 100% /snap/snap-store/518
tmpfs           787M   20K  787M   1% /run/user/1000
/dev/sda3        80G   72G  3.6G  96% /media/frank/e3ef9af4-7136-4650-8365-c6c02d0d14f4
/dev/sda1       209G   52G  158G  25% /media/frank/01D5FAEEFC8E1CB0

-i parameter will display used/available inodes instead of blocks;

$ df -i
Filesystem        Inodes  IUsed     IFree IUse% Mounted on
udev              998624    540    998084    1% /dev
tmpfs            1006237    996   1005241    1% /run
/dev/sda2       11558912 426817  11132095    4% /
tmpfs            1006237     49   1006188    1% /dev/shm
tmpfs            1006237      8   1006229    1% /run/lock
tmpfs            1006237     18   1006219    1% /sys/fs/cgroup
/dev/loop0          4485   4485         0  100% /snap/code/64
/dev/loop1          4485   4485         0  100% /snap/code/65
/dev/loop2         12841  12841         0  100% /snap/core/10958
/dev/loop3         12842  12842         0  100% /snap/core/11081
/dev/loop4         10817  10817         0  100% /snap/core18/1988
/dev/loop5         10790  10790         0  100% /snap/core18/1997
/dev/loop6         18513  18513         0  100% /snap/gnome-3-34-1804/60
/dev/loop7         18508  18508         0  100% /snap/gnome-3-34-1804/66
/dev/loop9         63978  63978         0  100% /snap/gtk-common-themes/1514
/dev/loop10        15847  15847         0  100% /snap/snap-store/498
/dev/loop8         64986  64986         0  100% /snap/gtk-common-themes/1515
/dev/loop11        15847  15847         0  100% /snap/snap-store/518
tmpfs            1006237     48   1006189    1% /run/user/1000
/dev/sda3        5316608   1536   5315072    1% /media/frank/e3ef9af4-7136-4650-8365-c6c02d0d14f4
/dev/sda1      164789844  13761 164776083    1% /media/frank/01D5FAEEFC8E1CB0

Using -T parameter will print the type of each filesystem;

$ df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs          tmpfs     787M  1.6M  785M   1% /run
/dev/sda2      ext4      173G  111G   54G  68% /
tmpfs          tmpfs     3.9G   28M  3.9G   1% /dev/shm
tmpfs          tmpfs     5.0M  4.0K  5.0M   1% /run/lock
tmpfs          tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0     squashfs  208M  208M     0 100% /snap/code/64
/dev/loop1     squashfs  208M  208M     0 100% /snap/code/65
/dev/loop2     squashfs  100M  100M     0 100% /snap/core/10958
/dev/loop3     squashfs   99M   99M     0 100% /snap/core/11081
/dev/loop4     squashfs   56M   56M     0 100% /snap/core18/1988
/dev/loop5     squashfs   56M   56M     0 100% /snap/core18/1997
/dev/loop6     squashfs  218M  218M     0 100% /snap/gnome-3-34-1804/60
/dev/loop7     squashfs  219M  219M     0 100% /snap/gnome-3-34-1804/66
/dev/loop9     squashfs   65M   65M     0 100% /snap/gtk-common-themes/1514
/dev/loop10    squashfs   52M   52M     0 100% /snap/snap-store/498
/dev/loop8     squashfs   66M   66M     0 100% /snap/gtk-common-themes/1515
/dev/loop11    squashfs   52M   52M     0 100% /snap/snap-store/518
tmpfs          tmpfs     787M   20K  787M   1% /run/user/1000
/dev/sda3      ext4       80G   72G  3.6G  96% /media/frank/e3ef9af4-7136-4650-8365-c6c02d0d14f4
/dev/sda1      fuseblk   209G   52G  158G  25% /media/frank/01D5FAEEFC8E1CB0

Knowing the type of the filesystem you can filter the output. You can show only filesystems of a given type with -t TYPE, or exclude filesystems of a given type with -x TYPE, like in the examples below.

Excluding tmpfs filesystems;

$ df -hx tmpfs
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
/dev/sda2       173G  111G   54G  68% /
/dev/loop0      208M  208M     0 100% /snap/code/64
/dev/loop1      208M  208M     0 100% /snap/code/65
/dev/loop2      100M  100M     0 100% /snap/core/10958
/dev/loop3       99M   99M     0 100% /snap/core/11081
/dev/loop4       56M   56M     0 100% /snap/core18/1988
/dev/loop5       56M   56M     0 100% /snap/core18/1997
/dev/loop6      218M  218M     0 100% /snap/gnome-3-34-1804/60
/dev/loop7      219M  219M     0 100% /snap/gnome-3-34-1804/66
/dev/loop9       65M   65M     0 100% /snap/gtk-common-themes/1514
/dev/loop10      52M   52M     0 100% /snap/snap-store/498
/dev/loop8       66M   66M     0 100% /snap/gtk-common-themes/1515
/dev/loop11      52M   52M     0 100% /snap/snap-store/518
/dev/sda3        80G   72G  3.6G  96% /media/frank/e3ef9af4-7136-4650-8365-c6c02d0d14f4
/dev/sda1       209G   52G  158G  25% /media/frank/01D5FAEEFC8E1CB0

Showing only ext4 filesystems;

$ df -ht ext4
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       173G  111G   54G  68% /
/dev/sda3        80G   72G  3.6G  96% /media/frank/e3ef9af4-7136-4650-8365-c6c02d0d14f4

Using the --output= parameter  followed by a comma separated list of fields you wish to display, you can customize the output of df selecting what should be displayed and in which order. i.e

  • source: The device corresponding to the filesystem.
  • fstype: The filesystem type.
  • size: The total size of the filesystem.
  • used: How much space is being used.
  • avail: How much space is available.
  • pcent: The usage percentage.
  • target: Where the filesystem is mounted (mount point).

The example below will display the target, source, type and usage;

$ df -h --output=target,source,fstype,pcent
Mounted on                                        Filesystem     Type     Use%
/dev                                              udev           devtmpfs   0%
/run                                              tmpfs          tmpfs      1%
/                                                 /dev/sda2      ext4      68%
/dev/shm                                          tmpfs          tmpfs      1%
/run/lock                                         tmpfs          tmpfs      1%
/sys/fs/cgroup                                    tmpfs          tmpfs      0%
/snap/code/64                                     /dev/loop0     squashfs 100%
/snap/code/65                                     /dev/loop1     squashfs 100%
/snap/core/10958                                  /dev/loop2     squashfs 100%
/snap/core/11081                                  /dev/loop3     squashfs 100%
/snap/core18/1988                                 /dev/loop4     squashfs 100%
/snap/core18/1997                                 /dev/loop5     squashfs 100%
/snap/gnome-3-34-1804/60                          /dev/loop6     squashfs 100%
/snap/gnome-3-34-1804/66                          /dev/loop7     squashfs 100%
/snap/gtk-common-themes/1514                      /dev/loop9     squashfs 100%
/snap/snap-store/498                              /dev/loop10    squashfs 100%
/snap/gtk-common-themes/1515                      /dev/loop8     squashfs 100%
/snap/snap-store/518                              /dev/loop11    squashfs 100%
/run/user/1000                                    tmpfs          tmpfs      1%
/media/frank/e3ef9af4-7136-4650-8365-c6c02d0d14f4 /dev/sda3      ext4      96%
/media/frank/01D5FAEEFC8E1CB0                     /dev/sda1      fuseblk   25%

df can also be used to check inode information, by passing the following fields to --output=;

  • itotal: The total number of inodes in the filesystem.
  • iused: The number of used inodes in the filesystem.
  • iavail: The number of available inodes in the filesystem.
  • ipcent: The percentage of used inodes in the filesystem.


$ df --output=source,fstype,itotal,iused,ipcent
Filesystem     Type        Inodes  IUsed IUse%
udev           devtmpfs    998624    540    1%
tmpfs          tmpfs      1006237    994    1%
/dev/sda2      ext4      11558912 426814    4%
tmpfs          tmpfs      1006237     49    1%
tmpfs          tmpfs      1006237      8    1%
tmpfs          tmpfs      1006237     18    1%
/dev/loop0     squashfs      4485   4485  100%
/dev/loop1     squashfs      4485   4485  100%
/dev/loop2     squashfs     12841  12841  100%
/dev/loop3     squashfs     12842  12842  100%
/dev/loop4     squashfs     10817  10817  100%
/dev/loop5     squashfs     10790  10790  100%
/dev/loop6     squashfs     18513  18513  100%
/dev/loop7     squashfs     18508  18508  100%
/dev/loop9     squashfs     63978  63978  100%
/dev/loop10    squashfs     15847  15847  100%
/dev/loop8     squashfs     64986  64986  100%
/dev/loop11    squashfs     15847  15847  100%
tmpfs          tmpfs      1006237     48    1%
/dev/sda3      ext4       5316608   1536    1%
/dev/sda1      fuseblk  164789844  13761    1%

Maintaining XFS Filesystems

For XFS filesystems, the equivalent of fsck is xfs_repair. If you suspect that something is wrong with the filesystem, the first thing to do is to scan it for damage. This can be done by passing the -n parameter to xfs_repair, followed by the device containing the filesystem. The -n parameter means “no modify”, the filesystem will be checked, errors will be reported but no repairs will be made;

$ sudo xfs_repair -n /dev/sda3
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
        - found root inode chunk
Phase 3 - for each AG...
        - scan (but do not clear) agi unlinked lists...
        - process known inodes and perform inode discovery...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
        - process newly discovered inodes...
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - check for inodes claiming duplicate blocks...
        - agno = 1
        - agno = 3
        - agno = 0
        - agno = 2
No modify flag set, skipping phase 5
Phase 6 - check inode connectivity...
        - traversing filesystem ...
        - traversal finished ...
        - moving disconnected inodes to lost+found ...
Phase 7 - verify link counts...
No modify flag set, skipping filesystem flush and exiting.

 You can proceed to do the repairs without the -n parameter if the errors are found i.e xfs_repair /dev/sda3;

xfs_repair accepts a number of command line options as follows.

  • -l LOGDEV and -r RTDEV: These are needed if the filesystem has external log and realtime sections. In this case, replace LOGDEV and RTDEV with the corresponding devices.
  • -m N: Is used to limit the memory usage of xfs_repair to N megabytes, something which can be useful on server settings. According to the man page, by default xfs_repair will scale its memory usage as needed, up to 75% of the system’s physical RAM.
  • -d: The “dangerous” mode will enable the repair of filesystems that are mounted read-only.
  • -v: You may have guessed it: verbose mode. Each time this parameter is used, the “verbosity” is increased (for example, -v -v will print more information than just -v).

xfs_db utility is used to debug XFS filesystem i.e. xfs_db /dev/sda3. This is mostly used to inspect various elements and parameters of the filesystem.

xfs_fsr utility, is used to reorganize (“defragment”) an XFS filesystem. When executed without any extra arguments it will run for two hours and try to defragment all mounted, writable XFS filesystems listed on the /etc/mtab/ file.


This marks the end of our guide on Maintaining The Integrity of Linux Filesystems. We hope you have found the guide informative.

More interesting guides below:

LPIC 101 – Managing Processes in Linux Systems

LPIC 101 – Processing Text Streams Using Filters on Linux

LPIC 101 – Compress and Uncompress Files Using tar, gzip, bzip2

LPIC 101 – Changing Runlevels and Boot Targets on Linux System