ZFS on LUKS and TRIM question

Hello everyone. My current setup (root on ZFS) looks like this:

% lsblk /dev/nvme1n1
NAME                                        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
nvme1n1                                     259:0    0 465.8G  0 disk  
└─luks-c73611b6-5e9d-4272-9c56-ede008b1f9b6 254:0    0 465.7G  0 crypt 
% zpool status zroot
  pool: zroot
 state: ONLINE

	NAME                                         STATE     READ WRITE CKSUM
	zroot                                        ONLINE       0     0     0
      luks-c73611b6-5e9d-4272-9c56-ede008b1f9b6  ONLINE       0     0     0

I enabled TRIM for LUKS by adding rd.luks.allow-discards to Dracut’s kernel_cmdline. The output of the following command contains allow_discards, which should indicate that TRIM is indeed enabled, IIUC.

# dmsetup table /dev/mapper/luks-c736[...] --showkeys

My question is, should TRIM be enabled via ZFS as well?

# zpool set autotrim=on zroot
1 Like

Hi. Yes, you should either enable autotrim or manually trim your pool periodically using zpool trim