What is tune2fs ?
tune2fs adjusts tunable filesystem parameters on a Linux second extended filesystem.
tune2fs brings the ability to modify various parameters on a file system volume that may not be the best or require some changes to reflect the needs of the environment. One example is Ubuntu: by default Ubuntu verifies file system integrity every 33 mounts/bootups or every 120 days(whichever comes first), while well intended the defaults may not be the best on a test or development system which may be subject to frequent reboots.
Tune2fs is easy to understand, I will walk you through what I consider to be some of the most common uses for tune2fs.
More Information
You can always consult the man pages for more information. Just use:
$ man tune2fs
Change integrity amount and time
I tend to boot Ubuntu more than 33 times a month, which is why I always increase the number of mounts.
$ sudo tune2fs -c 120 -i 3m /dev/sdb1 tune2fs 1.40.8 (13-Mar-2008) Setting maximal mount count to 120 Setting interval between checks to 7776000 seconds
– c max_mount_count This option is responsible for the number of mounts before the integrity check is done.
– i interval-between-checks This option is responsible for the mounts of days the system should wait before performing an integrity check. d = days | w = weeks | m = months, in this example the check is to be performed every 3 months -i 3M.
Disable file system integrity check
While dangerous some people may opt to disable checks all at once.
$ sudo tune2fs -i 0 /dev/sda1 tune2fs 1.40.8 (13-Mar-2008) Setting interval between checks to 0 seconds
-i 0 – This option disables checks based on time of the file system. Be careful the system will no longer perform integrity check after this options is selected.
Change the name of a volume
Changing the volume label name may be useful for personal labeling porpuses such as changing the name of a portable drive. Use the -l parameter to list the name of the filesystem superblock.
$ sudo tune2fs -l /dev/sda1 | grep volume Filesystem volume name: /home/user
Capital -L parameter will change the volume-label name. In this example I am changing the name from /home/user to myhome.
$ sudo tune2fs -L myhome /dev/sda1 tune2fs 1.40.8 (13-Mar-2008)
Verify the new name change.
$ sudo tune2fs -l /dev/sda1 | grep volume Filesystem volume name: myhome
Display file system superblock information
Lots of valuable information.
$ sudo tune2fs -l /dev/sdb1 tune2fs 1.40.8 (13-Mar-2008) Filesystem volume name: Last mounted on: Filesystem UUID: f060d692-53fd-4180-811c-f20bcf7f24d0 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype n eeds_recovery sparse_super large_file Filesystem flags: signed_directory_hash Default mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 3932160 Block count: 15727627 Reserved block count: 786381 Free blocks: 15557651 Free inodes: 3932146 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 1020 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 8192 Inode blocks per group: 256 Filesystem created: Sun May 9 00:43:38 2010 Last mount time: Sun May 9 01:05:38 2010 Last write time: Sun May 9 01:05:38 2010 Mount count: 2 Maximum mount count: 33 Last checked: Sun May 9 00:43:38 2010 Check interval: 15552000 (6 months) Next check after: Fri Nov 5 00:43:38 2010 Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128 Journal inode: 8 Default directory hash: tea Directory Hash Seed: 949c1e9b-19b3-437f-be23-05b14a671d3a Journal backup: inode blocks