You are not logged in.

#1 2013-12-22 18:02:50

doupod
Member
Registered: 2012-09-06
Posts: 73

[SOLVED] Trim with LUKS and a SSD

Hi,

I have a SSD with a LVM on LUKS setup. I have the discard option in my fstab, my SSD should support TRIM, my system is updated and the issue_discards option in LVM is set to 1, but it's never auto-trimmed.

I never managed to have trim working silently in the background with this setup, but I don't know if it's LUKS-related or not.

My only solution is to silently run fstrim via a cronjob, which is not that convenient.

Do you have any ideas regarding this problem ? Am I the only one with such a problem ? (I didn't find much info about this, and even less solutions...)

Thanks

EDIT : I've just realized something weird...

When I run "fstrim -v /", it echoes "/ : 51,6 GiB (55400726528 octets) taillés" and my partition / is a 68G partition.
Then if I run it again, I get "/ : 0 B (0 octets) taillés" which is normal and expected.

But, if I reboot the system and re-run it, it echoes again "/ : 51,6 GiB (55400726528 octets) taillés" whereas I think it should echo "/ : 0 B (0 octets) taillés"... Am I missing something ?

Last edited by doupod (2013-12-28 17:45:46)

Offline

#2 2013-12-22 18:15:47

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Trim with LUKS and a SSD

Don't you have to specifically allow discards on the mdadm level as well?

In any case, discards are blocking in SATA 3 and earlier, so using the discard mount option is not necessarily the most ideal.  Performance-wise, it is probably better to set up fstrim to run periodically on all trimmable mount points.  But if you have a relatively new device, garbage collection has improved greatly, and using TRIM is often times not actually necessary.

Offline

#3 2013-12-22 18:18:04

doupod
Member
Registered: 2012-09-06
Posts: 73

Re: [SOLVED] Trim with LUKS and a SSD

My device is not very recent. It's s SSD on a 1.5 years-old Clevo laptop.

So, according to you, the best idea would be to effectively launch fstrim manually (with a daily cronjob for example) ?

But, is the fstrim behaviour on my system normal ?

Offline

#4 2013-12-27 17:35:00

doupod
Member
Registered: 2012-09-06
Posts: 73

Re: [SOLVED] Trim with LUKS and a SSD

up

Offline

#5 2013-12-27 17:52:32

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,804

Re: [SOLVED] Trim with LUKS and a SSD

doupod wrote:

up

Please do not do that.  Read our policy


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Online

#6 2013-12-27 18:25:39

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED] Trim with LUKS and a SSD

I think you also need to manually enable trim for the encrypted device. You should probably read the first external link in that section about issues with TRIM and dmcrypt.

You might also be interested in this thread which seems to describe similar behaviour without encryption.

Last edited by alphaniner (2013-12-27 18:25:56)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#7 2013-12-28 17:45:26

doupod
Member
Registered: 2012-09-06
Posts: 73

Re: [SOLVED] Trim with LUKS and a SSD

@ewaller : I didn't have any more information about my problem, and my researches were not helping much. I'm sorry and apologize for this bumping...

@alphaniner : Thank you for your links. I looked at the "manually enable trim" thing but the discard option was set in my fstab, my kernel boot line and at the lvm level...

I looked at the other thread you pointed to me, with apparently the same behaviour, but no encryption (actually, I was assuming it was a problem due to encryption...) and found this link : http://nedoboi.wordpress.com/2011/11/12 … -it-works/

I tested this thing and the sectors were cleared after running fstrim. So, I assume fstrim is working.

Finally, I think I will drop the discard options in my fstab etc. (and forget about trying to get discard working) and just launch fstrim weekly from a crontask. It seems to be working, although its output is quite surprising...

Offline

Board footer

Powered by FluxBB