adjust tunable filesystem parameters on ext2/ext3/ext4

tune2fs [ -l ] [ -C mount-count ] [ -c max-mount-counts ]
[ -e errors-behavior ] [ -f ] [ -i interval-between-checks ]
[ -I new_inode_size ] [ -j ] [ -J journal-options ]
[ -o [^]mount-options[,…] ] [ -p mmp_update_interval ]
[ -s sparse-super-flag ]
[ -m reserved-blocks-percentage ] [ -r reserved-blocks-count ]
[ -u user ] [ -g group ] [ -U UUID ]
[ -E extended-options ]
[ -L volume-label ] [ -M last-mounted-directory ]
[ -O [^]feature[,...] ] [ -Q quota-options ] [ -T time-last-checked ] [ -z undo_file ]                     device

Adjust various filesystem parameters for ext2,ext3 and ext4 file systems

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., LABEL=home or UUID=e40486c6-84d5-4f2f-b99c-032281799c9d).

-c max-mounts the number of mounts after which the filesystem will be checked by e2fsck(8).
If max-mount-counts is 0 or -1, the number of times the filesystem is mounted will be disregarded

Staggering the mount-counts at which filesystems are forcibly checked will avoid all filesystems being checked at one time when using journaled filesystems. consequences of disabling mount-count-dependent checking entirely. journaling filesystem will never be marked dirty, so it will not normally be checked.
A filesystem error detected by the kernel will still force an fsck on the next reboot, too late to prevent data loss
See also the -i option for time-dependent checking.

-C mounts number of times the filesystem has been mounted. If greater than -c parameter e2fsck will check the filesystem at the next reboot.
-T time-last-checked time the filesystem was last checked using e2fsck. The time is interpreted using the current (local) timezone. This can be useful in scripts which use a Logical Volume Manager to make a consistent snapshot of a filesystem, and then check the filesystem during off hours to make sure it hasn't been corrupted due to hardware problems, etc. If the filesystem was clean, then this option can be used to last checked time on the original filesystem. The format of time-last-checked is the international date format, with an optional time specifier, i.e. YYYYMMDD[HH[MM[SS]]]. The keyword now is also accepted, in which case the last checked time will be set to the current time.
-e error-behavior behavior when errors are detected. filesystem error will cause e2fsck(8) to check the filesystem on the next boot.
continue Continue normal execution.
remount-ro Remount filesystem read-only.
panic Cause a kernel panic.
-E extended-options[,…
clear_mmp multiple mount protection

Set MMP block to the clean state. Use only if the device is not currently mounted or being fscked

mmp_update_interval=seconds initial MMP update interval to interval seconds.
0 : use the default interval. less than 300 seconds. Requires mmp be enabled.
stride=size Configure the filesystem for a RAID array with stride-size filesystem blocks.
the number of blocks read or written to disk before moving to next disk. This mostly affects placement of filesystem metadata like bitmaps at mke2fs(2) time to avoid placing them on a single disk, which can hurt the performance. It may also be used by block allocator.
stripe_width=width Configure the filesystem for a RAID array with stripe-width filesystem blocks per stripe. This is typically be stride-size * N, where N is the number of data disks in the RAID (e.g. RAID 5 N+1, RAID 6 N+2). This allows the block allocator to prevent read-modify-write of the parity in a RAID stripe if possible when the data is written.
hash_alg=legacy| half_md4|tea default hash algorithm used for filesystems with hashed b-tree directories.
mount_opts=options Set a set of default mount options which will be used when the file system is mounted.
Unlike the bitmask based default mount options which can be specified with the -o option, mount_option_string is an arbitrary string with a maximum length of 63 bytes, which is stored in the superblock.

ext4 first apples bitmask-based default options, and then mount_opts, before parsing the mount options passed from the mount

[^]test_fs may(not) be mounted using experimental code, such as the ext4dev filesystem.
-f Force the tune2fs operation to complete even in the face of errors. This option is useful when removing the has_journal filesystem feature from a filesystem which has an external journal (or is corrupted such that it appears to have an external journal), but that external journal is not available. If the filesystem appears to require journal replay, the -f flag must be specified twice to proceed. WARNING: Removing an external journal from a filesystem which was not cleanly unmounted without first replaying the exter- nal journal can result in severe data loss and filesystem corruption.
-i interval-between-checks[d|m|w] Adjust the maximal time between two filesystem checks. No suffix or d will interpret the number interval-between-checks as days, m as months, and w as weeks. A value of zero will disable the time-dependent checking. It is strongly recommended that either -c (mount-count-dependent) or -i (time-dependent) checking be enabled to force periodic full e2fsck(8) checking of the filesystem. Failure to do so may lead to filesystem corruption (due to bad disks, cables, memory, or kernel bugs) going unnoticed, ultimately resulting in data loss or corruption.
-I n inode size requires rewriting the inode table, the file system is checked for consistency first using e2fsck(8).
takes a long time and the file system can be corrupted and data lost if it is interrupted while in the middle of converting the file system.
-j Add ext3 journal
If the -J option is not specified, the default journal parameters will be used to create an appropriately sized journal (given the size of the filesystem) stored within the filesystem. Note that you must be using a kernel which has ext3 support in order to actually make use of the journal.

If this option is used to create a journal on a mounted filesystem, an immutable file, .journal, will be created in the top-level directory of the filesystem, as it is the only safe way to create the journal inode while the filesystem is mounted. While the ext3 journal is visible, it is not safe to delete it, or modify it while the filesystem is mounted; for this reason the file is marked immutable. While checking unmounted filesystems, e2fsck(8) will automatically move .journal files to the invisible, reserved journal inode. For all filesystems except for the root filesystem, this should happen automatically and naturally during the next reboot cycle. Since the root filesystem is mounted read-only, e2fsck(8) must be run from a rescue floppy in order to effect this transition. On some distributions, such as Debian, if an initial ramdisk is used, the initrd scripts will automatically convert an ext2 root filesystem to ext3 if the /etc/fstab file specifies the ext3 filesystem for the root filesystem in order to avoid requiring the use of a rescue floppy to add an ext3 journal to the root filesystem.

-J journal-options Override the default ext3 journal parameters. Journal options are comma separated, and may take an argument using the equals ('=') sign. options
size=MB Create a journal stored in the filesystem . at least 1024 filesystem blocks (i.e., 1MB if using 1k blocks, 4MB if using 4k blocks, etc.) and no more than 10,240,000 filesystem blocks. There must be enough free space in the filesystem to create a journal of that size.
location=location location of the journal. The location<.var> either a block number, or if the number has a units suffix (e.g., 'M', 'G', etc.) as the offset from the beginning of the file system.
device=external-journal Attach the filesystem to the journal block device located on external-journal. The external journal must have been already created using :
mke2fs -O journal_dev external-journal

that external-journal must be formatted with the same block size as filesystems which will be using it. In addition, while there is support for attaching multiple filesystems to a single external journal, the Linux kernel and e2fsck(8) do not currently support shared external journals .
Instead of specifying a device name directly, external-journal can also be specified by either LABEL=label or UUID=UUID to locate the external journal by either the volume label or UUID stored in the ext2 superblock at the start of the journal. Use dumpe2fs(8) to display a journal device's volume label and UUID. See also the -L option of tune2fs(8).

Only one of the size or device options can be given for a filesystem.
-l list the contents of the filesystem superblock, including the current values of the parameters that can be set via this program.
-L volume-label volume label of the filesystem. Ext2 filesystem labels can be at most 16 characters long; if volume-label is longer than 16 characters, tune2fs will truncate it and print a warning. The volume label can be used by mount(8), fsck(8), and /etc/fstab(5) (and possibly others) by specifying LABEL=volume-label instead of a block special device name like /dev/hda5.
-m reserved-blocks-percentage percentage of the filesystem which may only be allocated by privileged processes. Reserving some number of filesystem blocks for use by privileged processes is done to avoid filesystem fragmentation, and to allow system daemons, such as syslogd(8), to continue to function correctly after non-privileged processes are prevented from writing to the filesystem. Normally, the default percentage of reserved blocks is 5%.
-M last-mounted-directory last-mounted directory for the filesystem.
-o [^]mount-option[,...] Set or clear the indicated default mount options in the filesystem. Default mount options can be overridden by mount options specified either in /etc/fstab(5) or on the command line arguments to mount(8). Older kernels may not support this feature; in particular, kernels which predate 2.4.20 will almost certainly ignore the default mount options field in the superblock. More than one mount option can be cleared or set by separating features with commas. Mount options prefixed with a caret character ('^') will be cleared in the filesystem's superblock; mount options without a prefix character or prefixed with a plus character ('+') will be added to the filesystem. The following mount options can be set or cleared using tune2fs:
debug Enable debugging code for this filesystem.
bsdgroups Emulate BSD behavior when creating new files: they will take the group-id of the directory in which they were created. The standard System V behavior is the default, where newly created files take on the fsgid of the current process, unless the directory has the setgid bit set, in which case it takes the gid from the parent directory, and also gets the setgid bit set if it is a directory itself.
user_xattr Enable user-specified extended attributes.
acl Enable Posix Access Control Lists.
uid16 Disables 32-bit UIDs and GIDs. This is for interoperability with older kernels which only store and expect 16-bit values.
journal_data When the filesystem is mounted with journalling enabled, all data (not just metadata) is committed into the journal prior to being written into the main filesystem.
journal_data_ordered When the filesystem is mounted with journalling enabled, all data is forced directly out to the main file sys- tem prior to its metadata being committed to the journal.
journal_data_writeback When the filesystem is mounted with journalling enabled, data may be written into the main filesystem after its metadata has been committed to the journal. This may increase throughput, however, it may allow old data to appear in files after a crash and journal recovery.
nobarrier The file system will be mounted with barrier operations in the journal disabled. (This option is currently only supported by the ext4 file system driver in 2.6.35+ kernels.)
block_validity The file system will be mounted with the block_validity option enabled, which causes extra checks to be per- formed after reading or writing from the file system. This prevents corrupted metadata blocks from causing file system damage by overwriting parts of the inode table or block group descriptors. This comes at the cost of increased memory and CPU overhead, so it is enabled only for debugging purposes. (This option is currently only supported by the ext4 file system driver in 2.6.35+ kernels.)
discard The file system will be mounted with the discard mount option. This will cause the file system driver to attempt to use the trim/discard feature of some storage devices (such as SSD's and thin-provisioned drives available in some enterprise storage arrays) to inform the storage device that blocks belonging to deleted files can be reused for other purposes. (This option is currently only supported by the ext4 file system driver in 2.6.35+ kernels.)
nodelalloc The file system will be mounted with the nodelalloc mount option. This will disable the delayed allocation feature. (This option is currently only supported by the ext4 file system driver in 2.6.35+ kernels.)
-O [^]feature[,…] Set or clear the indicated features :
prefixed with a caret ('^') will be cleared ;
features without a prefix character or prefixed with a plus character ('+') will be added
For a detailed description of the file system features, please ext4(5).
dir_index Use hashed b-trees to speed up lookups for large directories.
dir_nlink Allow more than 65000 subdirectories per directory.
encrypt Enable file system level encryption. Can only be set.
extent Enable the use of extent trees to store the location of data blocks in inodes. Can only be set
extra_isize Enable the extended inode fields used by ext4.
filetype Store file type information in directory entries.
flex_bg Allow bitmaps and inode tables for a block group to be placed anywhere on the storage media. Tune2fs will not reorganize the location of the inode tables and allocation bitmaps, as mke2fs(8) will do when it creates a freshly formatted file system with flex_bg enabled.
has_journal Use a journal to ensure consistency across unclean shutdowns. equivalent to -j
huge_file Support files larger than 2 terabytes
large_file files can be are greater than 2GB.
metadata_csum Store a checksum to protect the contents in each metadata block.
mmp Enable or disable multiple mount protection (MMP) feature.
project Enable project ID tracking. for project quota tracking.
quota Enable internal file system quota inodes.
read-only Force mount read-only.
resize_inode Reserve space so the block group descriptor table may grow in the future. Can only be cleared
sparse_super Limit the number of backup superblocks to save space on large filesystems.
uninit_bg Allow the kernel to initialize bitmaps and inode tables lazily, and to keep a high watermark for the unused inodes in a filesystem, to reduce e2fsck(8) time. The first e2fsck run after enabling this feature will take the full time, but subsequent e2fsck runs will take only a fraction of the original time, depending on how full the file system is.
After setting or clearing sparse_super, uninit_bg, filetype, or resize_inode filesystem features, the file system may require being checked using e2fsck(8) to return the filesystem to a consistent state. Tune2fs will print a message requesting that the system administrator run e2fsck(8) if necessary. After setting the dir_index feature, e2fsck -D can be run to convert existing directories to the hashed B-tree format. Enabling certain filesystem features may prevent the filesystem from being mounted by kernels which do not support those features. In particular, the uninit_bg and flex_bg features are only supported by the ext4 filesystem.
-p mmp_check_seconds MMP check default. 5
-r blocks number of reserved filesystem blocks.
-Q quota-options
[^]usrquota Sets/clears user quota
[^]grpquota Sets/clears group quota
[^]prjquota Sets/clears project quota
-u user who can use the reserved blocks. numerical uid or name.
-g group group which can use the reserved blocks. numerical or name.
-U UUID universally unique identifier (UUID) of the filesystem. The format is a series of hex digits separated by hyphens, For example: "c1b9d5a2-f162-11cf-9ece-0020afc76f16".
The parameter may also be :
clear clear the filesystem
random generate new randomly-generated UUID
time generate new time-based UUID
used by mount(8), fsck(8), and /etc/fstab(5) by specifying UUID=uuid instead of a block special device
See uuidgen(8)
-z [undo_file Before overwriting a file system block, write the old contents of the block to an undo file for use with e2undo(8) to restore the old contents of the file system should something go wrong.
Default: $E2FSPROGS_UNDO_DIR/tune2fs-device.e2undo
Cannot be used to recover from a power fail or system crash.
AUTHOR tune2fs was written by Remy Card . It is currently being maintained by Theodore Ts'o . tune2fs uses the ext2fs library written by Theodore Ts'o . This manual page was written by Christian Kuhtz . Time-dependent checking was added by Uwe Ohse . AVAILABILITY tune2fs is part of the e2fsprogs package and is available from http://e2fsprogs.sourceforge.net.


From raspberry pi SD card (after resizer2fs -M (minimize size))
 >sudo tune2fs  -l /dev/mmcblk0p2
tune2fs 1.43.4 (31-Jan-2017)
Filesystem volume name:   rootfs
Last mounted on:          /
Filesystem UUID:          d4f0fd64-ad9d-4cfd-aa76-8d3541fbf008
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode 
                            dir_index filetype
                            needs_recovery extent flex_bg sparse_super 
                            large_file dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              410,448
Block count:              1,639,454
Reserved block count:        70,214
Free blocks:                417,560
Free inodes:              260,500
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      290
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8048
Inode blocks per group:   503
Flex block group size:    16
Filesystem created:       Tue Nov 28 21:49:13 2017
Last mount time:          Fri Mar 30 19:30:15 2018
Last write time:          Thu Nov  3 13:16:44 2016
Mount count:              1
Maximum mount count:      -1
Last checked:             Thu Nov  3 13:16:44 2016   
(was actually checked Fri Mar 30 15:30:15 2018 on Ubuntu before resize2fs)
Check interval:           0 ()
Lifetime writes:          32 GB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     32
Desired extra isize:      32
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      15cd42cf-166c-49b8-a582-73242849f77e
Journal backup:           inode blocks

sudo tune2fs -l /dev/mmcblk0p2 | grep Reserved Reserved block count: 70214 Reserved GDT blocks: 290 Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root)
SEE ALSO debugfs(8), e2fsck(8), mke2fs(8), ext4(5) dumpe2fs