Disk Partition alignment (Linux)
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:
- Partition_offset divided by Stripe_size
- 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:
For SCSI:
fdisk -lu /dev/sd<x>
For IDE:
fdisk -lu /dev/hd<x>
where
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
fdisk /dev/hda1
n
create a new partitionp
create a primary partitionl
create partition number 1- Select the defaults to use the whole disk or specify your required size.
t
set the partitions system ID as appropriatex
go into expert modeb
adjust the starting block number1
to choose the first partition- Type in the offset in sectors. For example a 64k RAID stripe size
and a 64k cluster size type in
64
.