Linux – SSD dm-crypt partition alignment

linuxssd

I have installed an Intel X25-M SSD in my work laptop. I want to encrypt this SSD with LUKS and install Ubuntu 10.04 on it. LVM is not needed so this will not be configured.

The articles on SSD i have read, explains that it is very important to align the partitions correctly. Therefore i run fdisk like this:

fdisk -H 32 -S 32 /dev/sda

Then i have created three partitions boot, swap and root. Could i just go on and continue to configure LUKS like explained in this article:

http://www.howtoforge.com/encrypting-the-system-manually-upon-installation-ubuntu8.04

And then everything will be aligned as it should? or does dm-crypt need to be aligned somehow?

Best Answer

Running fdisk like this:

fdisk -H 32 -S 32 /dev/sda

...is not quite sufficient. You also need to start the first partition at cylinder 2. (The first partition needs special treatment because it is automatically shifted by one track if you do not intervene. Source. And all this assumes your SSD uses a 512KB erase block size. That's what my OCZ uses, so this works for me.)

dm-crypt is generally a poor match for SSD's right now. While LVM will pass through the TRIM commands dm-crypt will not. Furthermore, TRIM, if it was used, would probably reduce security. Also, there are reports that overall SSD speed is drastically reduced by encryption, regardless of TRIM concerns. One forum user reported a drop from ~ 200 M/s to 50 M/s with encryption.