All of lore.kernel.org
 help / color / mirror / Atom feed
* [dm-crypt] cryptsetup align problem
@ 2010-08-25 21:50 Peter Smith
  2010-08-25 22:58 ` Milan Broz
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Smith @ 2010-08-25 21:50 UTC (permalink / raw)
  To: dm-crypt

I am trying to align a LUKS volume to 512K boundary. I calculate the
--align-payload value like this:

(512*1024) / 512 = 1024

cryptsetup luksFormat --align-payload=1024 /dev/sda1

When i confirm the task with cryptsetup luksDump /dev/sda2 the Payload
offset is set to 2048 which is 1024K?

What am i doing wrong?

cryptsetup version is 1.1.0-rc2, dmsetup library version is 1.02.39
and driver version is 4.15.0. Linux is 2.6.32-21.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dm-crypt] cryptsetup align problem
  2010-08-25 21:50 [dm-crypt] cryptsetup align problem Peter Smith
@ 2010-08-25 22:58 ` Milan Broz
  2010-08-26 12:43   ` Peter Smith
  0 siblings, 1 reply; 7+ messages in thread
From: Milan Broz @ 2010-08-25 22:58 UTC (permalink / raw)
  To: Peter Smith; +Cc: dm-crypt


On 08/25/2010 11:50 PM, Peter Smith wrote:
> I am trying to align a LUKS volume to 512K boundary. I calculate the
> --align-payload value like this:
> 
> (512*1024) / 512 = 1024
> 
> cryptsetup luksFormat --align-payload=1024 /dev/sda1
> 
> When i confirm the task with cryptsetup luksDump /dev/sda2 the Payload
> offset is set to 2048 which is 1024K?
> 
> What am i doing wrong?

Nothing, it works as expected. It is not fixed offset but req. alignment.

Using --align-payload=1024 means alignment to the nearest 512KiB boundary,
because the keyslots space requires more than 512KiB it aligns to next multiple
of it - i.e. 2048 sectors.

If you increase key size (thus keyslots size), it will probably switch to to 3072 etc.

Milan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dm-crypt] cryptsetup align problem
  2010-08-25 22:58 ` Milan Broz
@ 2010-08-26 12:43   ` Peter Smith
  2010-09-03 17:58     ` Christoph Anton Mitterer
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Smith @ 2010-08-26 12:43 UTC (permalink / raw)
  To: Milan Broz; +Cc: dm-crypt

Thanks, now it seeems very logical.

The system that is being configured has lvm on top of dm-crypt, are
there any benefits for using one value over another as long it is a
multiple of 512? e.g.

The LUKS volume is aligned to 1024K this is a multiple of 512 then lvm
is aligned to 512K with pvcreate --metadatasize 512k /dev/mapper/XXX,
i could also align dm-crypt to 4096K which is a multiple of 512 or
maybe align lvm to 1024K instead.

Would it make any difference?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dm-crypt] cryptsetup align problem
  2010-08-26 12:43   ` Peter Smith
@ 2010-09-03 17:58     ` Christoph Anton Mitterer
  2010-09-04  9:31       ` Peter Smith
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Anton Mitterer @ 2010-09-03 17:58 UTC (permalink / raw)
  To: Peter Smith; +Cc: dm-crypt

[-- Attachment #1: Type: text/plain, Size: 444 bytes --]

On Thu, 2010-08-26 at 14:43 +0200, Peter Smith wrote:
> The LUKS volume is aligned to 1024K this is a multiple of 512 then lvm
> is aligned to 512K with pvcreate --metadatasize 512k /dev/mapper/XXX,
> i could also align dm-crypt to 4096K which is a multiple of 512 or
> maybe align lvm to 1024K instead.
AFAIU --metadatasize has nothing (directly) to do with the alignment,
but just how much is reserved for metadata.

Cheers,
Chris.

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3387 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dm-crypt] cryptsetup align problem
  2010-09-03 17:58     ` Christoph Anton Mitterer
@ 2010-09-04  9:31       ` Peter Smith
  2010-09-05 10:07         ` Milan Broz
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Smith @ 2010-09-04  9:31 UTC (permalink / raw)
  To: dm-crypt

2010/9/3 Christoph Anton Mitterer
<christoph.anton.mitterer@physik.uni-muenchen.de>:
> On Thu, 2010-08-26 at 14:43 +0200, Peter Smith wrote:
>> The LUKS volume is aligned to 1024K this is a multiple of 512 then lvm
>> is aligned to 512K with pvcreate --metadatasize 512k /dev/mapper/XXX,
>> i could also align dm-crypt to 4096K which is a multiple of 512 or
>> maybe align lvm to 1024K instead.
> AFAIU --metadatasize has nothing (directly) to do with the alignment,
> but just how much is reserved for metadata.
>
> Cheers,
> Chris.
>

I do not understand LVM well enough to say if it is correct or not
regarding to metadatasize, but the reason why i am configuring it this
way is a statement from Theodore Ts'o:

"LVM likes to allocate 192k for its header information, and 192k is
not a multiple of 128k. So if you are creating file systems as logical
volumes, and you want those volume to be properly aligned you have to
tell LVM that it should reserve slightly more space for its meta-data,
so that the physical extents that it allocates for its logical volumes
are properly aligned"

The disk i am using has a erase block size on 512K, therefore my
values is different.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dm-crypt] cryptsetup align problem
  2010-09-04  9:31       ` Peter Smith
@ 2010-09-05 10:07         ` Milan Broz
  2010-09-05 15:07           ` Peter Smith
  0 siblings, 1 reply; 7+ messages in thread
From: Milan Broz @ 2010-09-05 10:07 UTC (permalink / raw)
  To: Peter Smith; +Cc: dm-crypt

On 09/04/2010 11:31 AM, Peter Smith wrote:
> I do not understand LVM well enough to say if it is correct or not
> regarding to metadatasize, but the reason why i am configuring it this
> way is a statement from Theodore Ts'o:

Teo's post is completely obsolete regarding default kvm metadata sizes.

Align cryptsetup to multiple of 1MiB
(2048 sectors in the cryptsetup) and you will have safe configuration.

If you do not understand LVM, please use most recent version and everything
will be aligned automatically.

It can be fine-tuned, but in most cases default is ok now.
(See "man pvcreate" --dataalignment if you want to force overwrite it.)

In lvm you can check alignment of PV with "pvs -o +pe_start --units k"
(If you have extent multiple of 512KiB then LVs are aligned automatically
even if fragmented - this is almost always true, default PE is 4M).

> The disk i am using has a erase block size on 512K, therefore my
> values is different.

1MiB is multiple of 512KiB so you are ok with above.

You do not need to align "to 512" but to "multiple of 512". Important
is that data start offset will start on erase block boundary.

Milan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dm-crypt] cryptsetup align problem
  2010-09-05 10:07         ` Milan Broz
@ 2010-09-05 15:07           ` Peter Smith
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Smith @ 2010-09-05 15:07 UTC (permalink / raw)
  To: Milan Broz; +Cc: dm-crypt

On Sun, Sep 5, 2010 at 12:07 PM, Milan Broz <mbroz@redhat.com> wrote:
>
> Teo's post is completely obsolete regarding default kvm metadata sizes.
>
> Align cryptsetup to multiple of 1MiB
> (2048 sectors in the cryptsetup) and you will have safe configuration.
>
> If you do not understand LVM, please use most recent version and everything
> will be aligned automatically.
>
> It can be fine-tuned, but in most cases default is ok now.
> (See "man pvcreate" --dataalignment if you want to force overwrite it.)
>
> In lvm you can check alignment of PV with "pvs -o +pe_start --units k"
> (If you have extent multiple of 512KiB then LVs are aligned automatically
> even if fragmented - this is almost always true, default PE is 4M).
>
>> The disk i am using has a erase block size on 512K, therefore my
>> values is different.
>
> 1MiB is multiple of 512KiB so you are ok with above.
>
> You do not need to align "to 512" but to "multiple of 512". Important
> is that data start offset will start on erase block boundary.
>
> Milan
>

Thank you very much, this information was what i needed to finally
configure my Intel SSD correctly.

I researched the info you provided, and i realized that the LVM
version and linux kernel used was already prepared for automatically
alignment. sysfs contained aligment_offset and
data_alignment_detection was enabled in lvm.conf.

Just for laughs i tested the --dataalignment option with 512k and this
also aligns the LVs, so if i was using an older linux kernel this
could be done.

99% of all information available about LVM and SSDs is copied from
Teo's article so i guess that many (including myself before i read
your post) will be using the --metadatasize option when configuring a
SSD and think that everything is okay.

If cryptsetup was able to use alignment information then nothing at
all had to be done when configuring LUKS and LVM on SSDs, although it
is easy to append the --align-payload=2048 option.

Anyway partitions->LUKS->LVM2->filesystem are now aligned on my disk,
thanks again.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-09-05 15:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-25 21:50 [dm-crypt] cryptsetup align problem Peter Smith
2010-08-25 22:58 ` Milan Broz
2010-08-26 12:43   ` Peter Smith
2010-09-03 17:58     ` Christoph Anton Mitterer
2010-09-04  9:31       ` Peter Smith
2010-09-05 10:07         ` Milan Broz
2010-09-05 15:07           ` Peter Smith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.