tune2fs
Modify ext2/ext3/ext4 filesystem parameters
TLDR
Set the max number of counts before a filesystem is checked to 2
Set the filesystem label to MY_LABEL
Enable discard and user-specified extended attributes for a filesystem
Enable journaling for a filesystem
SYNOPSIS
tune2fs [ options ] device
Common usage examples:
tune2fs -l /dev/sda1
tune2fs -c 30 -i 7d /dev/sdb1
tune2fs -j /dev/sdc1
tune2fs -O dir_index /dev/sdd1
tune2fs -L MyDataDisk /dev/sde1
PARAMETERS
-l
List the current contents of the filesystem superblock, including all tunable parameters and statistics.
-c max-mount-counts
Set the maximum number of times the filesystem may be mounted between two filesystem checks. A value of 0 or -1 disables this check.
-e errors-behavior
Set the behavior of the kernel when errors are detected. Options: continue (ignore errors), remount-ro (remount filesystem read-only), or panic (kernel panic).
-f
Force the operation to complete, even if errors or potential issues (like a dirty journal) are detected. Use with caution.
-i interval-between-checks
Set the maximum time (in days) between two filesystem checks. A value of 0 disables the time-dependent check.
-j
Add an ext3 journal to the filesystem. This effectively converts an ext2 filesystem to ext3 or ext4 (if also enabling ext4 features).
-J journal-options
Specify options for the ext3 journal. E.g., size=N (journal size in MB), device=external-journal (use an external journal device).
-m reserved-blocks-percent
Set the percentage of blocks reserved for the superuser. This ensures system stability even when the filesystem appears full to normal users.
-o [^]mount-options[,...]
Set or clear default mount options for the filesystem. Prepending with '^' clears the option. E.g., acl, user_xattr, journal_data.
-r reserved-blocks-count
Set the number of blocks reserved for the superuser, overriding the percentage set by -m.
-s [0|1]
Set or clear the sparse superblock feature. 0 clears, 1 sets. (Mostly deprecated in favor of -O sparse_super).
-t last-check-time
Set the time the filesystem was last checked. This is an internal field, usually updated by e2fsck or mount.
-u user
Set the user ID (UID) or username who can use the reserved blocks. Can be a numeric UID or a username.
-g group
Set the group ID (GID) or group name who can use the reserved blocks. Can be a numeric GID or a group name.
-O [^]feature[,...]
Set or clear filesystem features. Examples: has_journal, dir_index, ext_attr, resize_inode, extent. Prepending with '^' clears the feature.
-Q quota-options
Set quota options for the filesystem. E.g., usrquota, grpquota, pquota (project quota).
-L volume-label
Set the volume label of the filesystem (max 16 characters). This label can be used in /etc/fstab for mounting.
-M last-mounted-directory
Set the last mounted directory for the filesystem. (Informational only; updated by the mount command during actual mounts).
-U UUID
Set the Universally Unique Identifier (UUID) of the filesystem. Can be a specific UUID, clear (remove UUID), random (generate new random UUID), or time (generate time-based UUID).
-E extended-options
Set extended options for the filesystem, typically related to performance or specific hardware. E.g., stride=N, stripe-width=N (for RAID/LVM), mmp_update_interval=N (for Multiple Mount Protection).
-T time
Set the time the filesystem was last checked. Can take various time formats like now, today, or a specific date/time (e.g., 20231027103000).
device
The block device or image file containing the ext2/ext3/ext4 filesystem to be modified (e.g., /dev/sda1, /dev/mapper/vg0-lv0).
DESCRIPTION
tune2fs is a powerful utility for adjusting various tunable parameters of ext2, ext3, and ext4 filesystems. It allows system administrators to modify critical settings like the maximum mount count before an automatic filesystem check, the time interval between checks, the percentage of blocks reserved for the superuser, the volume label, and the universally unique identifier (UUID). Additionally, it's used for managing journaling options, converting an ext2 filesystem to ext3 or ext4 by adding a journal, and enabling or disabling filesystem features such as dir_index for optimized directory lookup. While many operations can be performed on a mounted filesystem, significant changes, especially to journaling or major feature flags, often require the filesystem to be unmounted or mounted read-only to prevent data corruption. tune2fs is an essential tool for fine-tuning filesystem behavior, enhancing stability, and customizing attributes without the need for a complete reformat.
CAVEATS
Most modifications, especially those affecting journaling or major feature flags (e.g., using -j or -O), should be performed on an unmounted filesystem.
Applying tune2fs to a mounted, read-write filesystem can lead to data corruption or an unstable system.
Always back up important data before making significant changes to a filesystem, as incorrect usage can render it unmountable or corrupt its data.
Some operations, like adding a journal, can take a considerable amount of time depending on the filesystem size.
FILESYSTEM FEATURES (<B>-O</B> OPTION)
The -O option allows granular control over various filesystem features that determine its capabilities and behavior. Examples include:
dir_index: Enables HTree directories for faster directory lookups.
has_journal: Enables journaling support (converts ext2 to ext3/ext4).
ext_attr: Enables extended attributes support.
filetype: Stores file type information in directory entries, improving some operations.
extent: Enables ext4 extent support for efficient large file allocation. Enabling or disabling these features can significantly impact filesystem behavior, performance, and compatibility.
JOURNALING MANAGEMENT
The -j option is used to add a journal to an ext2 filesystem, converting it to an ext3 or ext4 filesystem. This is a critical step for improving data integrity and recovery speed after a system crash by maintaining a log of metadata changes. The -J option provides further control over the journal, such as specifying its size (e.g., size=128M) or using an external device for the journal (e.g., device=/dev/sdb5), which can be beneficial for performance on busy systems by separating journal I/O from data I/O.
HISTORY
tune2fs is a fundamental component of the e2fsprogs package, which provides essential utilities for managing ext2, ext3, and ext4 filesystems in Linux. Its development has paralleled the evolution of these filesystems, adapting to new features such as journaling (introduced with ext3) and various performance enhancements in ext4. It has been a cornerstone utility for Linux filesystem administration since the early days of ext2, continuously updated to support the latest filesystem capabilities and ensure system stability and performance.