Filesystem Administration  «Prev  Next»

Lesson 2 Ext2 configuration, part 1
Objective Use the mke2fs command to adjust the filesystem's block size.

mke2fs Command

Linux provides a number of tools to configure and optimize filesystems. These tools, part of the e2fsprogs package, provide administrators with the functionality they need to get the most out of their Linux filesystems.
The e2fsprogs package provides the following tools.
  1. mke2fs
  2. tune2fs
  3. dumpe2fs
  4. debugfs

We will explore mke2fs in this lesson and the others in the following lesson.
"block size" is "the number of bytes allocated to individually accessible units in the ext2 filesystem."

mke2fs

Use the mke2fs command with the -b option to adjust the ext2 filesystem's block size. The block size should match the filesystem's expected usage, because block size directly impacts disk read and write performance.
Filesystems that have frequent, large file I/O operations, such as partitions containing executable programs, will perform better when the block size of the filesystem is larger than the default 1024 bytes. A block size of 4096 bytes is typically used.
When using these larger block sizes, each lookup into the filesystem retrieves more data. Unfortunately, if these files aren't exact multiples of the block size, more disk space will be wasted inside each block.
Filesystems that have many, small file I/O operations, such as partitions containing temporary files, will perform better with a smaller block size, such as 1024 bytes. In this scenario, the smaller files and smaller block size reduces wasted bytes at the end of blocks while not significantly affecting performance.
To use mke2fs to adjust the block size, provide the -b parameter and the partition name. For example, to adjust the /dev/hda5 partition to 2048 bytes, use mke2fs -b 2048 /dev/hda5.
Block size: Block size is the number of bytes allocated to individually accessible units in the ext2 filesystem.
The command mke2fs is destructive. mke2fs places a new, formatted filesystem onto the partition. If you mistakenly type the wrong partition name, you will overwrite all existing data!

Question: Enter the command to format /dev/hdb3 with a block size of 1024 bytes.
Answer: mke2fs -b 1024 /dev/hdb3

The next lesson discusses the use of tune2fs, dumpe2fs, and debugfs.