Legacy hard disks used 512 byte sectors. Partitions and logical volumes could potentially start on any sector boundary (in other words, at any multiple of 512 bytes from the start of the volume).

Newer disks (referred to as Advanced Format), SSDs, RAID controllers and SANs typically have block sizes larger than 512 bytes. For example, Advanced Format drives have a 4096 byte block size.

If the offset of a partition, offset of a logical volume or the block size of any filesystem is not consistent with the underlying disk, RAID controller or SAN, performance can suffer dramatically.

Volumes created with tools from Debian Wheezy will most likely have correct alignment. Unfortunately, there are still many cases where incorrect alignment may exist, for example, on a filesystem, LVM volume group or MD software RAID array created under older Debian versions. Problems can also arise in volumes that have been virtualized (converted into virtual machine disk image files) from older systems.

Procedure for checking for block alignment issues

Check the hardware (disks, RAID controllers, SAN)

Whether you have a single disk in a laptop, a server with a built-in RAID controller or a company SAN, it is important to discover the parameters relevant to block alignment.

For a directly connected hard disk, the hdparm utility may help:

$ sudo hdparm -I /dev/sda
        Logical  Sector size:                   512 bytes
        Physical Sector size:                   512 bytes

$ sudo hdparm -I /dev/sdb
        Logical  Sector size:                   512 bytes
        Physical Sector size:                  4096 bytes

In the example above, disk sda is an older disk with 512 byte sectors and sdb is a newer disk with 4096 byte sectors.

Check partitioning

$ sudo fdisk /dev/sda

This displays the starting byte for all partitions.

Take the start value, multiply it by the sector size (512) and divide by the sector size (e.g. 4096), if there is any remainder then the partition is not aligned and it is necessary to re-partition.

Check MD software RAID

Discover all the underlying volumes in each RAID volume:

$ sudo mdadm --detail /dev/md0

For each volume, check for the Data Offset:

$ sudo mdadm --examine /dev/sda7
    Data Offset : 262144 sectors
   Super Offset : 8 sectors
   Unused Space : before=262064 sectors, after=384 sectors

There is a branch of mdadm supporting custom data offsets during volume creation.

Check LVM physical volumes

$ sudo pvs -o +pe_start,vg_extent_size --units b
  PV         VG   Fmt  Attr PSize         PFree        1st PE   Ext
  /dev/md0   vg00 lvm2 a--  249665945600B 64822968320B 1048576B 4194304B

Look at the values under the "1st PE" and "Ext" columns, they should be divisible by the underlying block size.

Check filesystems

Check the block size of each filesystem.

$ sudo tune2fs -l /dev/mapper/vg00-home
Block size:               4096

Check any virtual machine disk image files