Disk Partition alignment (Linux)

From ben.goodacre.name/tech

Jump to: navigation, search

Disk partition alignment involves setting the partition offset of the first partition on a logical or physical hard-drive whilst taking into account the intended cluster size and any RAID striping of the volume. Aligning a partition correctly can have significant performance gains.


Rules for aligning

Both of following calculations must produce integers in order for the first partition on a disk (and therefore all subsequent partitions) to be correctly aligned:

  1. Partition_offset divided by Stripe_size
  2. Stripe_size divided by Cluster_size

For example a partition with offset of 64k, cluster size 64k and RAID stripe size of 64k (if applicable) will be correctly aligned. These settings will work best with disks that will contain databases. - The performance degradation of unaligned partition occurs during intensive I/O workloads rather than on those with low to moderate I/O activity.

How to ascertain these values

1. Partition offset:

fdisk -lu /dev/sd<x>

For IDE:

fdisk -lu /dev/hd<x>

where <x> is the device suffix.

Look for the 'Start' value for the partition that needs to be aligned. The values shown are in sectors, not cylinders.

2. Cluster size / File Allocation Unit size:
As root, type the following:

/sbin/dumpe2fs /dev/hda1 | grep 'Block size'
Replace /dev/hda1 as applicable

For the RAID stripe size, refer to your controller's documentation. For HP, install the Array Configuration Utility, part of the Proliant Support Pack.

How to create partitions that are aligned

Use fdisk: replace /dev/hda1 as applicable

See Also

Personal tools