tune2fs
**tune2fs**
is a command-line utility in Linux used to adjust various tunable filesystem parameters on ext2, ext3, and ext4 filesystems. This tool is part of the e2fsprogs package and is commonly used by system administrators to modify filesystem attributes after the filesystem has been created.
Overview of tune2fs
tune2fs
Basic Syntax
<device>
: The device or partition containing the filesystem to be modified (e.g.,/dev/sda1
).
Commonly Used Options
Adjusting Filesystem Parameters
-l
: Lists the current parameters of the filesystem.-c max-mount-counts
: Sets the number of times the filesystem can be mounted before a consistency check is forced.-i interval-between-checks[d|m|w]
: Sets the interval between forced filesystem checks.-r reserved-blocks-count
: Sets the number of reserved filesystem blocks.-m reserved-blocks-percentage
: Sets the percentage of the filesystem blocks reserved for the super-user.-e errors-behavior
: Sets the behavior when an error is detected (continue
,remount-ro
, orpanic
).-L volume-label
: Sets the volume label for the filesystem.-U UUID
: Sets the universally unique identifier (UUID) for the filesystem.-o mount-options
: Sets default mount options for the filesystem.-E extended-options
: Sets extended options likestripe
,resize
, etc.
Example Usage
Listing Filesystem Parameters
To list all current parameters of the filesystem on /dev/sda1
:
Setting Maximum Mount Count
To set the maximum mount count to 50 for /dev/sda1
:
Setting Interval Between Checks
To set the interval between forced filesystem checks to 30 days:
Setting Reserved Blocks Count
To set the number of reserved blocks to 5000:
Setting Reserved Blocks Percentage
To set the reserved blocks percentage to 1%:
Setting Error Behavior
To set the filesystem to remount as read-only on error:
Setting Volume Label
To set the volume label to "MY_LABEL":
Setting UUID
To set a new UUID for the filesystem:
Setting Default Mount Options
To set default mount options to noatime
and nodiratime
:
Setting Extended Options
To set an extended option such as resize
(resize inode size):
Advanced Examples
Reducing Reserved Space
By default, ext2/3/4 filesystems reserve 5% of the space for the root user. This is useful on root filesystems to avoid running out of space completely, but on large storage partitions, you might want to reduce this:
To set the reserved blocks percentage to 1% on a large storage partition:
Setting Filesystem Check Intervals
You might want to ensure that your filesystem is checked for consistency every 3 months:
Modifying Error Behavior
Setting the filesystem to panic on error can be useful for critical systems where data integrity is paramount:
Summary
**tune2fs**
is a versatile tool that allows administrators to optimize and control various aspects of ext2, ext3, and ext4 filesystems. Understanding and using tune2fs
can help in maintaining filesystem integrity, optimizing performance, and ensuring efficient use of disk space.
Last updated