# Trim, LUKS \[fstrim on encrypted btrfs SSD disk partition\]

**URL:** <https://forum.endeavouros.com/t/trim-luks-fstrim-on-encrypted-btrfs-ssd-disk-partition/16010>\
**Category:** General system\
**Created:** [July 22, 2021, 1:11am UTC](https://forum.endeavouros.com/t/trim-luks-fstrim-on-encrypted-btrfs-ssd-disk-partition/16010 "2021-07-22T01:11:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![linuxislife](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/linuxislife/32/91372_2.png) [@linuxislife](https://forum.endeavouros.com/u/linuxislife)\
**Post date:** [July 22, 2021, 1:11am UTC](https://forum.endeavouros.com/t/trim-luks-fstrim-on-encrypted-btrfs-ssd-disk-partition/16010/1 "2021-07-22T01:11:10Z")

</div>

Hey

So, i did enable periodic trim on my SSD. The `/` partition (p6 here), LUKS encrypted, didn’t seem to be able to be trimmed regarding the result of

```auto
$ lsblk --discard
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
├─nvme0n1p4 0 512B 2T 0
├─nvme0n1p5 0 512B 2T 0
└─nvme0n1p6 0 512B 2T 0
  └─luks-f6540be3-39bf-401d-8c00-5603b407b4cd 0 0 0 0

```

So, as per the [arch wiki](https://wiki.archlinux.org/title/Dm-crypt/Specialties#Discard/TRIM_support_for_solid_state_drives_(SSD)), i added the kernel parameters `:allow-discards` to the `cryptdevice` option and `rd.luks.options=discard` in the grub bootloader configuration.

I’m a bit confused with that part of the wiki: “for non-root filesystems, configure `/etc/crypttab` to include `discard` in the list of options”. As the luks partition is the `/` , can i just ignore this?

Actually, without modifying `/etc/crypttab`, the result of

```auto
$ lsblk --discard
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
├─nvme0n1p4 0 512B 2T 0
├─nvme0n1p5 0 512B 2T 0
└─nvme0n1p6 0 512B 2T 0
  └─luks-f6540be3-39bf-401d-8c00-5603b407b4cd 0 512B 2T 0

```

```auto
$ sudo dmsetup table
[sudo] Mot de passe de lmm : 
luks-f6540be3-39bf-401d-8c00-5603b407b4cd: 0 750565391 crypt aes-xts-plain64 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 259:6 4096 1 allow_discards

```

And if i do

```auto
$ sudo fstrim --verbose --all
[sudo] Mot de passe de lmm : 
/boot/efi : 67,4 MiB (70632448 octets) réduits sur /dev/nvme0n1p1
/boot : 416,4 MiB (436604928 octets) réduits sur /dev/nvme0n1p5
/ : 330,6 GiB (355009146880 octets) réduits sur /dev/mapper/luks-f6540be3-39bf-401d-8c00-5603b407b4cd

[lmm@lmm-hpebk840g7nbpc ~]$ sudo fstrim -v /
/ : 1,7 GiB (1875058688 octets) réduits

```

So i guess it’s good, I can safely ignore the `/etc/crypttab` part?

And, last but not least, does periodic trim worth the pain on this BTRFS file system? (and adding the security “risks” regarding the encryption)

Cheers !
