tune2fs command is one of the advanced unix commands which allows you to adjust various tunable parameters of the ext2/ext3 filesystems. Naturally, it also helps you confirm the existing parameters configured for your filesystems.
Confirm current filesystem parameters with tune2fs
The tunefs -l command will show you all the information contained in a filesystem's superblock. Here's how it typically looks:
ubuntu# tune2fs -l /dev/sda1 tune2fs 1.40-WIP (14-Nov-2006) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: d2ff8a06-74b7-4877-9d37-1873414e25b3 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal filetype needs_recovery sparse_super Default mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 2490368 Block count: 4980736 Reserved block count: 249036 Free blocks: 3417990 Free inodes: 2401957 First block: 0 Block size: 4096 Fragment size: 4096 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 16384 Inode blocks per group: 512 Filesystem created: Wed Sep 26 02:30:22 2007 Last mount time: Tue Apr 1 00:17:16 2008 Last write time: Tue Apr 1 00:17:16 2008 Mount count: 1 Maximum mount count: 29 Last checked: Tue Apr 1 00:16:22 2008 Check interval: 15552000 (6 months) Next check after: Sun Sep 28 00:16:22 2008 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: c0c5742c-980a-49b2-ae0b-4e96895376b6 Journal backup: inode blocks
Reserved space on a Unix filesystem
By default, every filesystem in Unix has some space reserved for the superuser (root). This means that no regular Unix user can fill your filesystem up to 100%, and so it's always going to have enough free space to continue normal function.
As a standard, each filesystem has 5% of space reserved in this way. If you look at the above output, you may notice the following lines there, which regulate the space reservation:
Reserved block count: 249036
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
Compared to the overall filesystem block count:
Block count: 4980736
this 249036 reserve is exactly 5%. The uid and gid confirm the Unix user id and Unix group id of the user who will be allowed to tap into the reserved space. As I said earlier, it's root.
If you have root access on your system, you can alter this reserved space allocation for any filesystem using tune2fs -m parameter, by specifying the percentage of the space to be reserved.
Here's how we change the default reserve to be 6% of the overall filesystem size:
ubuntu# tune2fs -m 6 /dev/sda1 tune2fs 1.40-WIP (14-Nov-2006) Setting reserved blocks percentage to 6% (298844 blocks)
And here we change it back. Note how the number of block corresponding to 5% is exactly the figure we've seen earlier – 249036 blocks:
ubuntu# tune2fs -m 5 /dev/sda1 tune2fs 1.40-WIP (14-Nov-2006) Setting reserved blocks percentage to 5% (249036 blocks)
Default block size for a filesystem
If you ever want to confirm the block size of any filesystem, tune2fs will help you do just that:
ubuntu# tune2fs -l /dev/sda1 | grep Block Block count: 4980736 Block size: 4096 Blocks per group: 32768
From this example, you can see that the default block size for the filesystem on /dev/sda1 partition is 4096 bytes, or 4k. That's the default block size for ext3 filesystem.