[arch-general] "Partition" alignment with LVM on LUKS

Mauro Santos registo.mailling at gmail.com
Wed Mar 12 15:17:33 EDT 2014


I've bought a new HD to replace one that is starting to show problems
intermittently. I'm planning to keep a very similar setup to what I have
currently, which uses LVM on LUKS.

Old HD has 512B physical sectors so alignment there was not a problem.
New HD however is an advanced format drive, that means a 4kB sector size
and 512B logical sector size, that's where problems can start.

The reason I'm asking for input on this is because I can't confirm with
a good degree of certainty if things are all properly aligned, by doing
and write and readback test (1).

Either my google fu is not working or it's hard to find information on
this. In [1] the question is similar but there is no answer.

The guide on [2] shows some commands with explicit alignment options but
the guide is not very recent. In [3] there is some general information
and some benchmarks, but no concrete information about lvm on luks. In
the wiki there is also mention to explicit alignment options but it's
related to SSDs so not the case for me.
The only one that seems to get close is [5], by looking at
/sys/block/sdXN/queue/minimum_io_size it says 4096. Also for all other
layers after that /sys/block/dm-[0-9]/queue/minimum_io_size (one belongs
to luks and otherers to lvm) it also says 4096 so I _suppose_ automatic
detection might leave things properly aligned.

Here's the sequence of commands I have used:
-used fdisk to create 2 partitions, used the suggested defaults for
start of partition

-used cryptsetup to format sda2, didn't use any alignment options

-opened the encrypted volume and used pvcreate on it, again didn't use
any alignment options

-used vgcreate to create a new VG and added the PV I created before

-used lvcreate to create several logical volumes, didn't use any
alignment options

-used mkfs.ext4 to format the logical volumes, also no alignment options
used.

I can't be 100% sure things are all aligned because of the following:
(1)
The machines I'm using now don't have AES-NI capable cpus, maximum
encryption and decryption speeds are lower than the maximum raw speed of
the hard disk (around 100MB/s).
The machine where I have the disk connected now can encrypt at 64.5
MiB/s and decrypt at 68.0 MiB/s according to cryptsetup benchmark.

Using 'dd if=/dev/zero of=testfile bs=10M count=100' I get 59.6 MB/s and
with 'dd if=testfile of=/dev/null bs=10M' I get 59.2 MB/s. These values
lead me to believe that everything is properly aligned. Unaligned reads
usually don't incur in much of a performance penalty, while unaligned
writes should make things slow to a crawl.

I would like to get some input from anyone with knowledge or hands on
experience on this before I commit to transplanting everything from the
current HD to the new one, better get this right the first time than to
have to redo it later again.

Sorry for the long post and thanks in advance for any input.


[1] https://bbs.archlinux.org/viewtopic.php?id=169841
[2]
http://danynativel.com/blog/2013/02/10/archlinux-installation-guide-on-encrypted-ssd/
[3] http://www.ibm.com/developerworks/linux/library/l-4kb-sector-disks/
[4] https://wiki.archlinux.org/index.php/Lvm#Installing_Arch_Linux_on_LVM
[5]
http://serverfault.com/questions/356534/ssd-erase-block-size-lvm-pv-on-raw-device-alignment


-- 
Mauro Santos


More information about the arch-general mailing list