tune2fs command in Linux is used to manipulate the filesystem parameters of a ext 2/3/4 type file system.
tune2fs command is part of e2fsprogs package.
Synopsis of the tune2fs command
The syntax for the
tune2fs [ -l ] [ -c max-mount-counts ] [ -e errors-behavior ] [ -f ] [ -i interval-between-checks ] [ -j ] [ -J journal-options ] [ -m reserved-blocks-percentage ] [ -o [^]mount-options[,...] ] [ -r reserved-blocks-count ] [ -s sparse-super-flag ] [ -u user ] [ -g group ] [ -C mount-count ] [ -E extended-options ] [ -L volume-name ] [ -M last-mounted-directory ] [ -O [^]feature[,...] ] [ -T time-last-checked ] [ -U UUID ] device
tune2fs command requires administrator privileges (root or sudo user) to operate.
Usage – tune2fs command
The usage of the
tune2fs command has been described below with examples.
How to list file system parameters using tune2fs?
The -l option is used with the
tune2fs command to list the current file system parameters.
sudo tune2fs -l /dev/sda2
How to set the volume label using tune2fs ?
The -L option is used with the
tune2fs command to set the volume label.
sudo tune2fs -L Label_Name /dev/sda2
You can verify the new volume label by using the -l option with the
sudo tune2fs -l /dev/sda2 | grep -i name
How to set maximum mount count using tune2fs?
The maximum mount count is the number of mounts after which the filesystem should be checked by the
e2fsck utility. By default it is set to -1, if the maximum mount count is 0 or -1 then it will be disregarded by the
To find out maximum mount count and mount count, execute:
sudo tune2fs -l /dev/sda2 | grep -i mount
The -c option is used with
tune2fs to set the maximum mount count, after which the filesystem should be checked by the
sudo tune2fs -c 40 /dev/sda2
How to set time intervals between two filesystem checks ?
The -i option with
tune2fs is used to set the time interval between two filesystem checks.
sudo tune2fs -i 3m /dev/sda2
The above command will check the filesystem every three months (m for months, w for weeks, & d for days) on
You can use both the maximum mount count and the time intervals between two filesystem checks.
sudo tune2fs -i 3m -c 150 /dev/sda2
How to disable filesystem check on reboot?
To disable filesystem check by
e2fsck utility on reboot, set the maximum mount count to -1 or 0.
Execute the following command to disable filesystem check on reboot:
sudo tune2fs -c 0 /dev/sda2 sudo tune2fs -i 0 /dev/sda2
How to set mount counts using the tune2fs command ?
The -C option is used with the
tune2fs command to set the number of times the filesystem has been mounted.
sudo tune2fs -C 37 /dev/sda2
If the mount count is set greater than the maximum mount count, then the filesystem will be checked by the
e2fsck utility at the next reboot.
How to set filesystem features using the tune2fs command ?
The -O option is used with
tune2fs to set filesystem features (features separated by a comma) in the indicated filesystem.
Note: Back up your data before using this option as it might corrupt your file system, and you may lose data.
sudo tune2fs -O uninit_bg,dir_index /dev/sda2
tune2fs is a great system utility for Linux System Administrators to adjust various ext 2/3/4 filesystems parameters. For a more detailed overview of the
tune2fs command, you can find its man page here.
Thank you for reading!