5

Is it necessary to have the partitions that makeup a software RAID 1 array be aligned?

This guide states

"Software RAID: Although one needs to pay attention to correct alignment here as well, this is not explicitly necessary as at least 64 KB-sized blocks are used."

I don't understand how Soft RAID changes the performance hit / write amplification issue given the underlying SSD controller is still staggering file system pages across more than necessary flash pages.

Here is one of my drives, I believe that the partition starting at LBA 63, means I'm not aligned. Partitions were created via CentOS 5 installer.

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      610469      305203+  fd  Linux raid autodetect
/dev/sda2          610470    16996769     8193150   fd  Linux raid autodetect
/dev/sda3        16996770    25189919     4096575   fd  Linux raid autodetect
/dev/sda4        25189920   234436544   104623312+   5  Extended
/dev/sda5        25189983   234436544   104623281   fd  Linux raid autodetect

Thank you so much!

2 Answers 2

4

It is not necessary, everything will work and probably still much faster than spinning metal based drives, but better alignment will further improve performance particularly for write operations.

Newer installations get this right out of the box automatically (current Debian/Stable certainly does, no doubt newer CentOS variants will too) because recent releases of fdisk, lvm, mdadm, and related tools have been updated to account for best practise on these newer drive technologies, but for older releases you need to set your partitions up more manually to get the best out of your SSDs.

It should be possible to realign in-place but it would be much safer IMO to backup the data on the machine and rebuild - in either case the downtime involved might make this not worth the hassle for you.

4
  • link at the bottom says: "LVM and Software RAID: Although one needs to pay attention to correct alignment here as well, this is not explicitly necessary as at least 64 KB-sized blocks are used. This doesn't make sense to me. If the partitions underlying the array aren't aligned, won't soft RAID 1 still run into this problem? This seems to say not really. Thanks David!
    – charles s
    Apr 30, 2014 at 15:32
  • 1
    If the block devices (whole disks, partitions, RAID volumes) your PVs are hosted in are correctly aligned, then all the LVs in the VGs using those PVs will be correctly aligned too as everything LVM does is done on 64KiB or 1MiB boundaries within those containers. If the block device holding a PV is misaligned though, everything in that PV will be misaligned. May 1, 2014 at 11:58
  • I read that quote as: "Software RAID or LVM obviates the need for partition alignment due to their internal workings", whereas, I believe you are saying "as long as your partitions are aligned to the disk's physical storage boundaries, RAID ON TOP of those partitions will be aligned b/c they deal in multiples of 4k, as such always align to physical pages on the physical device." Correct?
    – charles s
    May 1, 2014 at 17:14
  • 1
    That is correct - even if they put there metadata at the start of the block device alignment of the volumes they provide is maintained, but they don't know the underlying physical device so have to just assume that alignment is fine to start with. May 3, 2014 at 10:17
0

Yes, file system alignment matters, especially with RAID, and possibly even more with SSDs, to avoid unnecessary read and write amplification. Optimal alignment is workload dependent.

Disclosure: link above is to an article I wrote on this subject.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .