Adjust file system parameters

To tune file system parameters on a Linux ext2, ext3, or ext4 file system, you can use the tune2fs command. The syntax of this command is simple: you just type tune2fs, followed by the options and the file system device name. Here are the most common options and their description:

  • -c NUMBER – ext2fs, ext3fs, and ext4fs file systems require a periodic disk check with fsck. This check is designed to prevent errors from creeping onto the disk undetected. This option specifies the maximum number of mounts between two file system checks.
  • -i INTERVAL [d|m|w] – specifies the maximum time interval between two consecutive file system checks in days (d), months (m), or weeks (w). Normally, interval is a number with the character d, w, or m appended, to specify days, weeks, or months, respectively.
  • -j – adds a journal to the file system, converting an ext2 file system into an ext3 file system.
  • -l – displays contents of the file system’s superblock, which contains partition information.
  • -f – forces completion of the tune2fs command even in an error condition.
  • -m – sets the percentage of disk space that’s reserved for use by the root user.
  • -L – specifies the volume label for a file system.

For example, to change the maximum number of mounts between two file system checks on the /dev/sdc1 partition to 30, you use the following command:

linux tune2fs command mounts

It is not recommend to run tune2fs on a mounted file system.

 

The xfs_admin command is the rough equivalent of tune2fs for XFS file systems. Here are the most common options used with this command:

  • -l – prints the current file system label.
  • -L – changes the file system’s label.
  • -U – changes the file system’s UUID.

To display the existing label for an XFS file system and then apply a new label, you can use the following commands:

linux xfs_admin command

 

You must unmount a file system before using the xfs_admin command.
Geek University 2022