Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Getting a new laptop with SSD tomorrow. I need to know about the current status of dm-crypt and TRIM. I have seen several conflicting reports and most activity around this question seems to be > 1 year old. Some say that dm-crypt TRIM passthrough has been included in multiple recent kernel versions (which is not a problem for me, since I use Arch). Some say that the support still does not exist. Can I get a clear, well-sourced answer on the status of dm-crypt TRIM support? git commits or mailing list announcements that mention this feature would be ideal.

The answer to this question has big potential to influence the way I architect my new laptop's disks. Hopefully it will be useful to some others to have a decent, up-to-date answer.

share|improve this question
up vote 8 down vote accepted

For the record, this functionality did NOT exist when I first posted this question. I asked on the mailing list and was informed by Milan Broz that discard passthrough for dm-crypt targets still had not been implemented. Milan indicated that he intended to implement this at some point, but did not state when.

After digging around in dm-crypt.c and related files for a while, it appeared that TRIM support would be fairly trivial to add. I wrote the list asking for their general advisement on the task before I jumped in. The next day, Milan submitted a patch that implements TRIM pass-through on dm-crypt and this has been staged into linux-next. It should be included in the Linux 3.1 kernel.

TRIM passthrough must be enabled explicitly. There are potential security issues in using TRIM on a dm-crypt'd device, because TRIM sends information about block usage to the firmware on the device which then marks recently freed areas as usable (as I understand it, anyway). This means that an interested party can derive information about patterns of disk usage. For instance, it was postulated that an attacker could almost definitely learn what filesystem was in use on the encrypted medium through this data. An attacker may also be able to learn more useful information, like that you had a lot of big files saved until recently (big contiguous TRIM'd blocks).

Please see these threads for reference:

tl;dr: TRIM passthrough support for dm-crypt targets will exist in Linux >= 3.1 but must be enabled manually via cryptsetup and/or dmsetup due to data leakage that may allow profiling based on disk usage patterns.

share|improve this answer

As of kernel 3.2.x, dm-crypt + brtfs is supposed to be safe. See the reply to my question from Chris Mason: and

share|improve this answer

According to this post...

My question is: What happens, if a dm-crypt-layer is between the filesystem and the real block-device? Will the trim be passed through, or will it be discarded?

It guess it will be passed through. I'm using btrfs on a SSD which is encrypted with LUKS/dmcrypt, and it works great. Btrfs uses ata trim quite a while.

You might also need discard in mount options of the filesystem.

share|improve this answer
Thanks, but that answer is still non-definitive and over a year old. I would like a definitive, recent answer. I guess I will have to mail the list, just hoping SU would be a quick shortcut :p – cookiecaper Jun 27 '11 at 18:14
Well, if it already worked a year ago... – grawity Jun 27 '11 at 18:28
"I guess it works because my SSD is not slow" is not really a reliable indicator of whether TRIM support is actually functional. – cookiecaper Jun 28 '11 at 4:14
Which is exactly what I have never said. – grawity Jun 28 '11 at 9:11
That's what the post you've quoted says. – cookiecaper Jul 20 '11 at 7:04

well there's this thread

and this tool

I haven't used it yet, but I'm also interested in this problem.

share|improve this answer
Thanks honig, I had found that before. Please see the answer I just added, it provides detail on real discard support for dm-crypt targets. – cookiecaper Aug 4 '11 at 4:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.