Table of Contents
In this article, we will look into 13 Useful tune2fs Commands to Manage Ext2/Ext3/Ext4 Filesystem. tune2fs is an open source utility in Linux which allows System or Linux Administrators to adjust various tunable filesystem parameters on Linux ext2, ext3, or ext4 filesystems. We will see some very useful examples of this command in below section.
tune2fs Commands to Manage Ext2/Ext3/Ext4 Filesystems
Also Read: 5 Easy Steps to Download and Install Firefox Browser on Ubuntu 20.04
Example 1: How to View Filesystem Parameters in Linux
If you want to view all the Filesystem parameters in Linux, then you need to use tune2fs -l <filesystem>
command as shown below. In this example, we are checking all the filesystem metrics of /dev/sda5
using tune2fs -l /dev/sda5
command.
root@localhost:~# tune2fs -l /dev/sda5 tune2fs 1.45.5 (07-Jan-2020) Filesystem volume name: <none> Last mounted on: / Filesystem UUID: 77e6d563-f3d9-405f-b343-c81e4f6be66b Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 4554752 Block count: 18218240 Reserved block count: 910912 Free blocks: 15607014 Free inodes: 4350542 First block: 0 Block size: 4096 Fragment size: 4096 Group descriptor size: 64 Reserved GDT blocks: 1024 Blocks per group: 32768 Fragments per group: 32768
NOTE:
Example 2: How to Check the "Mount Count" of a Filesystem in Linux
You can check the mount count of a filesystem by grepping the Mount count parameter from tune2fs
command output as shown below. Here the Mount count value of /dev/sda5
filesystem is 13
.
root@localhost:~# tune2fs -l /dev/sda5 | grep "Mount count" Mount count: 13
Example 3: How to Check Filesystem "Volume Name" Using tune2fs command
To check the volume name of /dev/sda5
filesystem, you need to grep volume keyword from tune2fs
command as shown below. In this example /dev/sda5
filesystem does not have any volume name set.
root@localhost:~# tune2fs -l /dev/sda5 | grep volume Filesystem volume name: <none>
Example 4: How to Change Filesystem "Volume Name" in Linux
If you want to change the filesystem volume name, then you need to use -L
option with tune2fs command as shown below. Here we are changing the volume name of /dev/sda5
filesystem to example_volume
using tune2fs -L example_volume /dev/sda5
command as shown below.
root@localhost:~# tune2fs -L example_volume /dev/sda5 tune2fs 1.45.5 (07-Jan-2020) root@localhost:~# tune2fs -l /dev/sda5 | grep volume Filesystem volume name: example_volume
Example 5: How to Change "Maximum Mount Count" of a filesystem to 20
If you want to change the Maximum mount Count
of a Filesystem then you need to specify the count value with -c
option as shown below. In this example, we are changing the Maximum mount count
of /dev/sda5
filesystem using tune2fs -c 20 /dev/sda5
command as shown below.
root@localhost:~# tune2fs -c 20 /dev/sda5 tune2fs 1.45.5 (07-Jan-2020) Setting maximal mount count to 20 root@localhost:~# tune2fs -l /dev/sda5 | grep "Maximum mount count" Maximum mount count: 20
Example 6: How to View "Check Interval" value of a Filesystem
To view the check Interval value of a filesystem, you need to grep the Check Interval keyword from tune2fs command output as shown below. In this example, we are checking the value of /dev/sda5
filesystem using tune2fs -l /dev/sda5 | grep "Check interval"
command.
root@localhost:~# tune2fs -l /dev/sda5 | grep "Check interval" Check interval: 0 (<none>)
Example 7: How to Disable Filesystem Check on Boot in Linux
To disable filesystem check on boot, you need to set both Maximum mount count
and Filesystem check
to a value of -1
. In this example, we are disabling the filesystem check on boot for /dev/sda5
using below mentioned tune2fs command.
root@localhost:~# tune2fs -c -1 /dev/sda5 tune2fs 1.45.5 (07-Jan-2020) Setting maximal mount count to -1 root@localhost:~# tune2fs -i -1 /dev/sda5 tune2fs 1.45.5 (07-Jan-2020) tune2fs: interval between checks is too big (18446744073709465216)
Example 8: How to Convert Ext2 Filesystem to Ext3 Filesystem
If you want to convert ext2 filesystem to ext3 filesystem, then you need to use -j
option with tune2fs command as shown below. In this example, we are converting filesystem of /dev/sda1
from ext2 to ext3 using tune2fs -j /dev/sda1
command.
root@localhost:~# tune2fs -j /dev/sda1
NOTE:
Example 9: How to Set Last Filesystem Check Timestamp to Current Time
If you want to set the Last Filesystem check timestamp to current time then you need to use tune2fs -T now <filesystem>
command. In this example, we are setting the last filesystem check timestamp to current time using tune2fs -T now /dev/sda5
command as shown below.
root@localhost:~# tune2fs -T now /dev/sda5 tune2fs 1.45.5 (07-Jan-2020) Setting time filesystem last checked to Sun May 2 15:45:04 2021
Example 10: How to Set Maximal time between two Filesystem Checks
If you want to set maximal time between two filesystem checks to X number of days then you need to specify the number of days with -i
option as shown below. In this example, we are setting the filesystem check of /dev/sda5 to 20 days using tune2fs -i 20d /dev/sda5
command. This will set the maximal time between two checks of /dev/sda5
filesystem to 20 days
.
root@localhost:~# tune2fs -i 20d /dev/sda5 tune2fs 1.45.5 (07-Jan-2020) Setting interval between checks to 1728000 seconds
Example 11: How to Convert Ext3 Filesystem to Ext4 Filesystem in Linux
If you want to convert ext3 filesystem to ext4 filesystem, then you need to use -O
option with tune2fs command as shown below. Here you need to set some features with -O
option. In this example, we are converting filesystem of /dev/sda5
from ext3 to ext4 using tune2fs -O extents,uninit_bg,dir_index /dev/sda5
command.
root@localhost:~# tune2fs -O extents,uninit_bg,dir_index /dev/sda5
NOTE:
Example 12: How to Change Error Behavior of a Filesystem in Linux
If you want to change the behavior of a Kernel code when errors are detected then you need to use -e
option and set the behavior. In this example, we are setting the behavior of /dev/sda5
filesystem to continue using tune2fs -e continue /dev/sda5
command as shown below. It means that Kernel will continue to boot normally even if there is an error detected from /dev/sda5
filesystem. The other options which can be used are remount-ro
and panic
.
root@localhost:~# tune2fs -e continue /dev/sda5 tune2fs 1.45.5 (07-Jan-2020) Setting error behavior to 1
Example 13: How to Check the Man Page of tune2fs Commands
If you want to check the man page of tune2fs command then you need to use man tune2fs
command as shown below. More on tune2fs command.
root@localhost:~# man tune2fs TUNE2FS(8) System Manager's Manual TUNE2FS(8) NAME tune2fs - adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems SYNOPSIS tune2fs [ -l ] [ -c max-mount-counts ] [ -e errors-behavior ] [ -f ] [ -i interval-between-checks ] [ -I new_inode_size ] [ -j ] [ -J journal-op‐ tions ] [ -m reserved-blocks-percentage ] [ -o [^]mount-options[,...] ] [ -r reserved-blocks-count ] [ -u user ] [ -g group ] [ -C mount-count ] [ -E extended-options ] [ -L volume-label ] [ -M last-mounted-directory ] [ -O [^]feature[,...] ] [ -Q quota-options ] [ -T time-last-checked ] [ -U UUID ] [ -z undo_file ] device DESCRIPTION tune2fs allows the system administrator to adjust various tunable filesystem parameters on Linux ext2, ext3, or ext4 filesystems. The current values of these options can be displayed by using the -l option to tune2fs(8) program, or by using the dumpe2fs(8) program. The device specifier can either be a filename (i.e., /dev/sda1), or a LABEL or UUID specifier: "LABEL=volume-label" or "UUID=uuid". (i.e., LA‐ BEL=home or UUID=e40486c6-84d5-4f2f-b99c-032281799c9d).