Skip to contentSkip to conversation

luks2 and discard/trim not working

dm-crypt Nikolay Kichukov 1 participant 1 message May 8, 2020

lore
Share & tools
lore
#0 lore raw

Hello folks,

Recently, I upgraded to LUKS2 on a NVME SSD disk and noticed that fstrim does not work. Surely it was running fine with LUKS1.

Here are some more details:

GNU/Gentoo Linux
kernel: 5.5.13-gentoo-x86_64
sys-fs/cryptsetup-2.2.2

NVME supports discard and fstrim on filesystem on nvme0n1p2(without LUKS2 encyption) works fine:

NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
nvme0n1 0 512B 2T 0

├─nvme0n1p1         0      512B       2T         0
├─nvme0n1p2         0      512B       2T         0
└─nvme0n1p3         0      512B       2T         0
  └─root_dif        0        0B       0B         0
    └─root          0        0B       0B         0

dmsetup table /dev/mapper/root | grep allow
0 947028136 crypt capi:rfc7539(chacha20,poly1305)-random :32:logon:cryptsetup:6ae40ec7-1b4c-40ea-871b-d13c9ae66b92-d0 0 254:0 0 2 allow_discards integrity:28:aead

cryptsetup status root
/dev/mapper/root is active and is in use.
type: LUKS2
cipher: chacha20-random
keysize: 256 bits
key location: keyring
integrity: poly1305
device: /dev/nvme0n1p3
sector size: 512

  offset:  0 sectors
  size:    947028136 sectors
  mode:    read/write
  flags:   discards 

However:
fstrim -v /
fstrim: /: the discard operation is not supported

Any ideas?

Thanks,
-Nikolay