tune2fs Command Examples in Linux

tune2fs is a command-line utility used for adjusting the parameters of an ext2, ext3, or ext4 filesystem. These are the file systems commonly used in Linux distributions. This tool allows users to modify various parameters of the file system, such as the maximum number of files that can be stored, the maximum size of files, and the interval for performing periodic file system checks.

Using tune2fs, users can adjust the file system parameters while the file system is still mounted. This can be useful in situations where it is not feasible to unmount the file system, such as when the file system is being used by a critical application or when it is the root file system.

Some of the parameters that can be modified using tune2fs include the following:

  • Reserved Block Percentage: This parameter specifies the percentage of disk space reserved for the root user. By default, 5% of the disk space is reserved for the root user. However, this can be changed using tune2fs.
  • Maximum Number of Inodes: Inodes are data structures used by the file system to store information about files and directories. By default, the ext file systems reserve one inode for every 16KB of disk space. Using tune2fs, users can adjust this value to meet their needs.
  • Maximum File Size: This parameter specifies the maximum size of a file that can be stored on the file system. By default, ext file systems support files up to 16 TB in size. However, this value can be changed using tune2fs.

tune2fs Command Examples

1. Set the max number of counts before a filesystem is checked to 2:

# tune2fs -c 2 /dev/sdXN

2. Set the filesystem label to MY_LABEL:

# tune2fs -L 'MY_LABEL' /dev/sdXN

3. Enable discard and user-specified extended attributes for a filesystem:

# tune2fs -o discard,user_xattr /dev/sdXN

4. Enable journaling for a filesystem:

# tune2fs -o^nobarrier /dev/sdXN

Summary

In summary, tune2fs is a powerful command-line tool that allows users to adjust various parameters of an ext2, ext3, or ext4 file system. The tool is highly customizable and can be used on mounted file systems. It is an essential tool for Linux system administrators and can be used to optimize file system performance and improve the overall stability of the system.

Related Post