Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have encrypted my SSD with dm-crypt/LUKS to install an Archlinux in an LVM container. Here's a graph of the structure (it's in French but should be understandable):


Now I realised I should have aligned my partitions for better SSD performances (like explained here).

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      481949      240943+  83  Linux
/dev/sda2          481950   250069679   124793865   83  Linux

My question is: can I (and how) correct the misalignment of my partitions or should I reinstall everything? Knowing that the second partition is encrypted and contains an LVM container.

share|improve this question
up vote 3 down vote accepted

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

share|improve this answer
Thanks, so no way to resize a lukscontainer ? Concerning LVM, only the PV should be aligned I assume ? – Martin Trigaux Jan 23 '13 at 12:05
Yes you have to align the lukscontainer and the pv. Regarding the LVM you should keep in mind that your physicalextentsize (which you can specify while creating a VG) should be a multiple of your alignment. – morlix Jan 23 '13 at 14:02
ok thanks I'll do that. Too bad I have to reinstall :-/ – Martin Trigaux Jan 23 '13 at 16:58

You must log in to answer this question.

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