A commonly used and very simple alternative to partition alignment is to create the file system directly on the storage device without any paritions. To do this, you would just use mkfs without any partition number, e.g. for XFS:

$ mkfs.xfs /dev/sdb

Thus, you would easily avoid the misalignment, which is introduced by a partition table.

By default, Linux uses a 512 bytes alignment (to be more specific: 63*512 bytes) for the first primary partition on a device. This is fine for single disks, at least the traditional ones, that use 512 byte blocks. For RAID arrays or SSDs, you want to set a different alignment to avoid the overhead of read-modify-write operations and enable the internal XFS or ext4 RAID optimizations.

Note that if you are using other software layers like LVM on a RAID, these can also introduce another offset and thus need to be taken into account for proper alignment.

Example configuration: In our example, we use a 600GB volume on:

an array of 11 disks

in RAID-6 mode

with a stripe size of 64KB

as device /dev/sdc

With RAID-6, we effectively have 9 disks for user data, so we want to align to 9 * 64KB.

(For SSDs, you probably want to align to the erase block size, which is typically 512KB or a multiple of that.)

As mentioned above, we want to align to 9*64KB. We will use the fdisk arguments "-H 8 -S 16" to manually specify the (logical) number of heads and sectors. These arguments allow us to create a partition that is aligned to 64KB or any multiple of 64KB.

Our settings are based on 64KB cylinders and we want our partition to start right after the first stripe set (9 cylinders), so we will set the first cylinder to 10.

$ fdisk -H 8 -S 16 /dev/sdc
The number of cylinders for this disk is set to 9155272.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-9155272, default 1): 10
Last cylinder or +size or +sizeM or +sizeK (10-9155272, default 9155272):
Using default value 9155272
Command (m for help): w
The partition table has been altered!

XFS and ext4 allow you to specify RAID settings. This enables the file system to optimize its read and write access for RAID alignment, e.g. by committing data as complete stripe sets for maximum throughput. These settings can be made at file system creation time or, in the case of XFS, also later at mount time.

Note that these RAID optimizations can significantly improve performance, but only if your partition is properly aligned or of you are avoiding misalignment by creating the xfs on a device without partitions.

To create a new XFS file system for 9 disks (where the number 9 does not include the number of RAID-5 or RAID-6 parity disks) and 64KB chunk size, use:

$ mkfs.xfs -d su=64k,sw=9 -l version=2,su=64k /dev/sdc1

Note: If your data is stored on a RAID-5 or RAID-6 volume, you might want to consider putting the file system journal on a separate RAID-1 volume, due to the read-modify-write overhead of RAID-5 and RAID-6.