4

I am currently trying to set up multiple devices with Ubuntu (20.04.5 LTS) and the drive must be encrypted, so I used LUKS during the installation. (I checked "Use LVM with the new Ubuntu installation" + "Encrypt the new Ubuntu installation for Security" in the process)

However, the encrypted drive is much slower (as expected), but I read this article about the possibility to speed up dm-crypt I/O operations, using two flags no_read_workqueue and no_write_workqueue (last paragraph). FYI: I am using a NVMe SSD. The patch has been merged into the Linux Kernel 5.9 and onwards, I have 5.14, so it should be available for me. How can I enable this by default?

I have already changed the /etc/crypttab file by adding the flags:

nvme0123abcdef-etc UUID=123abcdef-etc none luks,discard,no-write-workqueue,no-read-workqueue

That hasn't changed the speed at all.

I tried to set the default flags:

cryptsetup --perf-no_read_workqueue --perf-no_write_workqueue --persistent refresh root

then I will get an error: --perf-no_read_workqueue: unknown option

Furthermore the flags are not shown when I use cryptsetup luksDump /dev/sdaX | grep Flags -> (This shows "none") or dmsetup table -> (This shows allow_discards)

FYI: I used this Wikipage for infos: https://wiki.archlinux.org/title/Dm-crypt/Specialties

1

2 Answers 2

2

I had the same idea with Debian 11.

After modifying /etc/crypttab you need to run

sudo update-initramfs -k all -u 

to update the boot config. If this command shows a warning, these options are not supported on your system. This is the case with Debian 11 (but runtime changes are supported).

You can check the current flags using this command:

sudo dmsetup table nvme0n1p3_crypt --showkeys 0 3515592704 crypt aes-xts-plain64 :64:logon:cryptsetup:asdf-asdf-asdf-asdf 0 259:3 32768 1 allow_discards 

You can change the options during runtime using:

sudo cryptsetup refresh nvme0n1p3_crypt --perf-no_read_workqueue --perf-no_write_workqueue --allow-discards 

Unfortunately, it forces you the enter the disk encryption key again which makes automation hard.

However, the options do not seem to be without drawbacks. On my system (Ryzen 2700 + WD SN570 2TB) the sequential write performance drops by 25% while the random I/O performance increases by 30%.

0

The problem is most likely that your cryptsetup package is too old. Support for these performance flags were added in version 2.3.4 (see release notes), but Ubuntu 20.04 only provides version 2.2.2 (see Ubuntu packages).

So your best bet is probably to upgrade to a newer distro.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.