Slow performace of LUKS encryption on SSD

OS: Manjaro XFCE 64-bit
Kernel: 5.4 LTS
CPU: Intel Core i7-4790
Memory: 32GB
SSD: Samsung 860 EVO 1TB SATA SSD, with the latest firmware

Hi all,

This is the output of cryptsetup benchmark on my system:

[john@manjarolinuxdesktop ~]$ cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1      1618172 iterations per second for 256-bit key
PBKDF2-sha256    1801676 iterations per second for 256-bit key
PBKDF2-sha512    1424695 iterations per second for 256-bit key
PBKDF2-ripemd160 1166380 iterations per second for 256-bit key
PBKDF2-whirlpool  811591 iterations per second for 256-bit key
argon2i       7 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
argon2id      7 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
#     Algorithm |       Key |      Encryption |      Decryption
        aes-cbc        128b       729,9 MiB/s      2972,2 MiB/s
    serpent-cbc        128b        95,2 MiB/s       629,3 MiB/s
    twofish-cbc        128b       193,8 MiB/s       396,4 MiB/s
        aes-cbc        256b       552,2 MiB/s      2320,2 MiB/s
    serpent-cbc        256b        99,1 MiB/s       630,7 MiB/s
    twofish-cbc        256b       201,8 MiB/s       394,5 MiB/s
        aes-xts        256b      2012,7 MiB/s      1999,8 MiB/s
    serpent-xts        256b       623,0 MiB/s       609,2 MiB/s
    twofish-xts        256b       389,0 MiB/s       390,9 MiB/s
        aes-xts        512b      1639,2 MiB/s      1617,3 MiB/s
    serpent-xts        512b       628,9 MiB/s       610,1 MiB/s
    twofish-xts        512b       390,9 MiB/s       390,8 MiB/s
[john@manjarolinuxdesktop ~]$

However with cryptsetup LUKS encryption, on my SSD, its read/write speed is about 439MB/sec:

[manjarolinuxdesktop ~]# /sbin/sysctl -w vm.drop_caches=3
vm.drop_caches = 3
[manjarolinuxdesktop ~]# dd if=/mnt/other_partition/something.vdi of=/dev/null bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1,1 GB, 1,0 GiB) copied, 2,4435 s, 439 MB/s
[manjarolinuxdesktop ~]# 
[manjarolinuxdesktop ~]# cryptsetup luksDump /dev/sda1
LUKS header information for /dev/sda1

Version:       	1
Cipher name:   	aes
Cipher mode:   	xts-plain64
Hash spec:     	sha256
Payload offset:	4096
MK bits:       	256

With key size 512 bits, the read/write speed is a bit slower.

With no encryption, the read/write speed is 559MB/sec.

Why do I get this slow read/write speed from SSD (439 MB/sec), while the cryptsetup benchmark, shows much higher speeds?

Thank you a lot.

There are more older discussion about this, but i'll let just this two here:

Thank you for your reply.

I think those two discussion threads, look like they are not related with my issue.

You mean they do not deal with performance of LUKS ? Ok.

cryptsetup benchmark runs in RAM I would guess. Your disk will be slower that's normal.

The solution for me is to place:


in file: /etc/modules-load.d/modules.conf

I hope this helps.

1 Like

That is for CPU if is capable to deal with AES NI, some CPUs do not. Kernels have that enabled, but the module needs to be specified to load and be used. :slight_smile:

Forum kindly sponsored by