Re: wrong luks header backup file size after conversion to LUKS2

Ondrej Kozina <[email protected]> Fri, 16 Feb 2024 09:24:44 +0100
Newsgroups dev.linux.lists.cryptsetup
Message-ID <[email protected]>
Hi,

On 15/02/2024 21:20, T.Gavrylko wrote:
> Hi,
> Recently I successfully converted LUKS1 partition to LUKS2 and created
> a header backup after the conversion.
> LUKS1 root partition was created by opensuze tumbleweed installer
> The length of this header backup file is wrong: 2097152 bytes what is
> corresponding to the LUKS1 header size.

AFAICT the header size seems correct to me. There's no definitive 
correct header size and The LUKS2 header size may be up to 256 MiBs size 
depending the luksFormat parameters.

Your original data offset was probably at (LUKS1 default value) sector 
4096 (2097152 bytes, see the luksDump output). After the conversion the 
data offset remained the same since we do not move encrypted data in 
convert command. The LUKS2 header after the conversion cannot be larger 
that 2097152 bytes since it would otherwise overwrite your data beyond 
data offset.

With regards
O.

> (...)
> 
> luksDump:
> 
> sudo cryptsetup luksDump /dev/nvme0n1p9
> LUKS header information
> Version:        2
> Epoch:          8
> Metadata area: 16384 [bytes]
> Keyslots area: 2064384 [bytes]
> UUID:          3d6055ea-4ab5-4dd0-8f3b-93f51dcc6ddd
> Label:          1n1p9-OS-R
> Subsystem:      (no subsystem)
> Flags:        (no flags)
> 
> Data segments:
>    0: crypt
> offset: 2097152 [bytes]

see       ^^^^^^^^

> length: (whole device)
> cipher: aes-xts-plain64
> sector: 512 [bytes]
> 
(...)