Correct misaligned encrypted partitions

The problem is, that you have to shrink the cryptsetup luks container which is currently not possible (growing is possible, but not shrinking).

So you have to reinstall everything or use a rescue linux from a usb stick and do the following:

  1. backup the content of all your LVs
  2. delete the volumegroup and the logical volumes
  3. delete the cryptsetup container
  4. align the partitions (which means delete the old and create new aligned partitions)
  5. create the cryptsetup container (see the note 1 below)
  6. Create a aligned PV (see note 2 below)
  7. Create the VG
  8. Create all needed LVs
  9. Create your filesystems
  10. Restore your data/system

Note 1: Please remind that you should not at least align your partitions, you should align every container/block device on your ssd or a 4KB Sector hdd.

To correctly align your cryptsetup container for a 4KB sector drive use the following formula:

alignment (512Byte sectors) = (sector size (Byte)) / 512

alignment (512Byte sectors) = (4KB * 1024) / 512 = 8

So you should add the following to your cryptsetup command: --align-payload=8

Note 2: To create a aligned PV you should go sure that the start of the PV's data (pe_start) is aligned on a full 4KB sector width boundary.

Please keep in mind that your physicalextentsize (which you can specify while creating a VG) should be a multiple of your alignment.

So you should add the following to your pvcreate command: --dataalignment 8s