Course contentsShow
← Linux
Lesson 634 of 1,8197. Storage Management and Logical VolumesFree lesson

Filesystem performance tuning

Optimize mount options and block alignment for specific storage hardware configurations.

In this lesson, you will learn how to optimize filesystem performance by selecting the right mount options and ensuring your partitions are physically aligned with your storage hardware.

Understanding Mount Options

When you mount a filesystem, the kernel applies default settings that balance safety and speed. However, you can tune these for your specific needs using the /etc/fstab file. For instance, if you are using an SSD or a workload where file access timestamps aren't critical, you can reduce unnecessary write operations.

Adding the noatime option prevents the kernel from writing to the disk every time a file is read, which significantly reduces overhead on flash storage.

# Example /etc/fstab entry
/dev/sdb1  /data  ext4  defaults,noatime,nodiratime  0  2

The Importance of Block Alignment

Performance also hinges on how your filesystem's internal data structures align with the physical layout of your drive. Modern drives, especially SSDs and RAID arrays, have "physical blocks" (often 4KB or larger). If your partition start sector is not aligned with these physical blocks, a single file system operation might require two physical I/O operations instead of one, a phenomenon known as "misalignment."

When creating a filesystem, you should ensure the start offset aligns with the drive’s stripe size or page size. For example, when using mkfs.ext4, the utility usually detects the underlying geometry, but for complex hardware like hardware RAID or SAN volumes, you can manually define the stride and stripe-width:

# Example: Creating an ext4 filesystem aligned to a RAID stripe of 64KB
mkfs.ext4 -b 4096 -E stride=16,stripe-width=16 /dev/sdb1
  • stride=16 tells the filesystem that each RAID chunk is 16 blocks (16 * 4KB = 64KB).
  • stripe-width tells the filesystem the full stripe size, helping it distribute data across all disks in the array efficiently.

By aligning your filesystem structures with the hardware's physical block geometry, you minimize the "read-modify-write" penalty and ensure that your system reads the maximum amount of data in a single request.

Key Takeaway: Performance tuning is achieved by minimizing unnecessary metadata writes via mount options like noatime and ensuring your partition boundaries match your storage device’s physical block architecture.