You are not logged in.

#1 2017-05-04 11:40:56

tnek
Member
Registered: 2008-06-10
Posts: 41

[SOLVED] dm-crypt + luks and periodic TRIM

I want to use periodic TRIM in a dm-crypt + luks system.

My SSD supports TRIM:

[root@archzenbook]# lsblk -D
NAME                                          DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                                                  0      512B       2G         0
├─sda1                                               0      512B       2G         0
└─sda2                                               0      512B       2G         0
  └─luks-92797f9d-9c23-4ea4-a1db-5adad0658cd1        0      512B       2G         0

I thought I'd stay away from Continuous TRIM as I don't know how good my SSD's BIOS is at doing that. But I would like to get Periodic TRIM working so I enabled the fstrim.timer:

[root@archzenbook]# systemctl enable fstrim.timer
Created symlink /etc/systemd/system/timers.target.wants/fstrim.timer → /usr/lib/systemd/system/fstrim.timer.

But reading this section in the wiki about dm-crypt and TRIM made me confused. Do I need to do something more to get periodic trim working?

Is there a way to tell if periodic trim was successful after it has run?

Last edited by tnek (2017-05-05 11:29:17)

Offline

#2 2017-05-04 11:48:31

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] dm-crypt + luks and periodic TRIM

Which part of the dm-crypt trim article that you linked to don't you understand?

It clearly tells you what extra steps need to be taken.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2017-05-04 12:09:34

frostschutz
Member
Registered: 2013-11-15
Posts: 1,658

Re: [SOLVED] dm-crypt + luks and periodic TRIM

LUKS needs allow discard flag to be set.

You can check with dmsetup table

yourluks: 0 9999 crypt aes-xts-plain64 0000 0 0:0 4096 1 allow_discards
       	       	       	       	       	       	       	 ^^^^^^^^^^^^^^

or the more generic yes-trim-test https://unix.stackexchange.com/a/85880/30851

Offline

#4 2017-05-05 11:29:04

tnek
Member
Registered: 2008-06-10
Posts: 41

Re: [SOLVED] dm-crypt + luks and periodic TRIM

slithery wrote:

Which part of the dm-crypt trim article that you linked to don't you understand?

It clearly tells you what extra steps need to be taken.

Yes, when I looked at it now with rested eyes I wouldn't improve it. It's clear enough as it is.

frostschutz wrote:

LUKS needs allow discard flag to be set.

You can check with dmsetup table

yourluks: 0 9999 crypt aes-xts-plain64 0000 0 0:0 4096 1 allow_discards
       	       	       	       	       	       	       	 ^^^^^^^^^^^^^^

or the more generic yes-trim-test https://unix.stackexchange.com/a/85880/30851

I added the discard option to my systemd-boot entry:

echo "options luks.options=discard" >>/boot/loader/entries/arch.conf

Rebooted and could verify that it worked

[root@archzenbook]# dmsetup table
luks-92797f9d-9c23-4ea4-a1db-5adad0658cd1: 0 499063439 crypt aes-xts-plain64 0000000000000000000000000000000000000000000000000000000000000000 0 8:2 4096 1 allow_discards

The verification part was not in (that part at least) of the wiki so it was of great value! Thanks!

Offline

Board footer

Powered by FluxBB