Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #188649

Re: how to enable trim for an external encrypted SSD?

From Christian Seiler <christian@iwakd.de>
Newsgroups linux.debian.user
Subject Re: how to enable trim for an external encrypted SSD?
Date 2017-11-06 14:30 +0100
Message-ID <uIPDr-3uR-9@gated-at.bofh.it> (permalink)
References <uIOo1-2L5-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Am 2017-11-06 13:09, schrieb Joerg Desch:
> Now I have bought a SanDisk Extreme Portable SSD. My goal is to add a 
> LUKS
> encrypted partition without an explicit fstab entry. I've done this 
> with
> some USB thumbdrives before, but not with TRIM support. The drvie 
> should
> be plugged into any Linux device without the need to change the
> configuration.
> 
> What is the correct way to add TRIM support to an external SSD with 
> LUKS
> encrypted partition?

I don't what you want is possible. When you plug in an external drive
(that is _not_ in /etc/fstab etc.) the process of how it gets mounted
is different:

  - For configured drives (/etc/fstab etc.) the init system (e.g.
    systemd, but also initscripts when you are using sysvinit) will
    read /etc/crypttab and /etc/fstab and apply those options to
    the LUKS container and the filesystem.

  - For non-configured drives the 'udisks' helper program will
    enable the user to decrypt & mount those devices.

Now, at least the ext4 filesystem allows you to set default mount
options, such as 'discard':

    tune2fs -o +discard /dev/external_disk_device

btrfs on the other hand tries to auto-detect SSDs and enable
discard automatically if on an SSD - but I have no idea whether that
works under LUKS or not.

But all that doesn't really help you if the underlying LUKS container
isn't opened with the discard option set. And as far as I know there
is no possibility of tagging a LUKS container with that option, you
must always supply that option to the cryptsetup command (which is
done implicitly via /etc/crypttab).

And while you might be able to reconfigure udisks to pass the discard
option to cryptsetup (though I'm also doubtful about that), that
configuration would have to happen on each individual computer, and
can't be put onto the external drive.

In summary:

  - If your filesystem is not encrypted, btrfs out of the box, and
    ext4 with the proper option set, should make it possible to
    automatically enable mounting with the correct option.

  - But I don't know of any method to tag a LUKS container so that it
    is opened with TRIM support by default.

Hence I don't think what you want is possible with the current state
of affairs, unfortunately. Sorry.

You could ask the LUKS developers to include an additional flag in
their headers that allows you to specify that this volume should be
opened with discards allowed by default - to maybe solve this in the
very long term. No idea how amenable they'd be towards that though,
as they do discourage the usage of TRIM in LUKS because it weakens
possible security guarantees somewhat.

Regards,
Christian

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

how to enable trim for an external encrypted SSD? Joerg Desch <news@jdesch.de> - 2017-11-06 13:10 +0100
  Re: how to enable trim for an external encrypted SSD? Christian Seiler <christian@iwakd.de> - 2017-11-06 14:30 +0100
    Re: how to enable trim for an external encrypted SSD? "Alexander V. Makartsev" <avbetev@gmail.com> - 2017-11-06 21:10 +0100
      Re: how to enable trim for an external encrypted SSD? Michael Stone <mstone@debian.org> - 2017-11-06 21:50 +0100
        Re: how to enable trim for an external encrypted SSD? "Alexander V. Makartsev" <avbetev@gmail.com> - 2017-11-06 22:30 +0100
          Re: how to enable trim for an external encrypted SSD? Michael Stone <mstone@debian.org> - 2017-11-06 23:10 +0100
            Re: how to enable trim for an external encrypted SSD? "Alexander V. Makartsev" <avbetev@gmail.com> - 2017-11-07 00:20 +0100
              Re: ow to enable trim for an external encrypted SSD? dekkzz78@gmail.com - 2017-11-07 13:40 +0100
          Re: how to enable trim for an external encrypted SSD? Henrique de Moraes Holschuh <hmh@debian.org> - 2017-11-07 02:10 +0100
      Re: how to enable trim for an external encrypted SSD? Joerg Desch <news@jdesch.de> - 2017-11-07 08:20 +0100
    Re: how to enable trim for an external encrypted SSD? Joerg Desch <news@jdesch.de> - 2017-11-07 08:10 +0100
    Re: how to enable trim for an external encrypted SSD? Joerg Desch <news@jdesch.de> - 2017-11-11 14:10 +0100
      Re: how to enable trim for an external encrypted SSD? Christian Seiler <christian@iwakd.de> - 2017-11-11 14:20 +0100
        Re: how to enable trim for an external encrypted SSD? Joerg Desch <news@jdesch.de> - 2017-11-11 14:40 +0100
          Re: how to enable trim for an external encrypted SSD? Christian Seiler <christian@iwakd.de> - 2017-11-11 15:30 +0100
            Re: how to enable trim for an external encrypted SSD? Joerg Desch <news@jdesch.de> - 2017-11-11 16:50 +0100
              Re: how to enable trim for an external encrypted SSD? Stefan Monnier <monnier@iro.umontreal.ca> - 2017-11-16 04:10 +0100
                Re: how to enable trim for an external encrypted SSD? Joerg Desch <news@jdesch.de> - 2017-11-21 18:40 +0100
    Re: how to enable trim for an external encrypted SSD? Christian Seiler <christian@iwakd.de> - 2017-12-18 13:20 +0100

csiph-web