All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mistave <mistave@countermail.com>
To: dm-crypt@saout.de
Subject: [dm-crypt] Properly enabling TRIM for dm-crypt on an SSD
Date: Sun, 20 Dec 2020 12:36:00 +0100	[thread overview]
Message-ID: <1e91347d-24ba-a387-e148-b3dd96bf0adc@countermail.com> (raw)

Hello!

I have some questions about the TRIM/discard for LUKS-encrypted SSDs.

I currently have a custom Ubuntu 20.04 LTS setup with encrypted ext4
rootfs partition (it's /dev/sda2 and /dev/sda1 is the EFI partition) on
an HDD that I'd like to migrate to an SSD. I was originally going to do
a block-for-block copy using dd, but I figured it'd be better and faster
to copy just the files from rootfs and the EFI partition rather than the
entire disk. So I'm going to setup a new LUKS volume (same parameters)
on the SSD and then sync the filesystem contents over there.

This got me thinking about optimizing the system for SSD since it was
originally installed on an HDD. While googling for information I found
out about two types of TRIM: continuous and periodic. The docs say that
the continuous mode is activated by adding a "discard" parameter to the
rootfs mount options in /etc/fstab or by activating a certain flag by
tune2fs. The periodic mode is activated by placing the fstrim utility on
a timer i.e. a weekly cron job or systemd timer. I noticed the latter is
already active on my system.

Anyway, I was wondering how this is handled when dm-crypt lies between
the SSD and the filesystem. Do I need to take any additional steps in
this case or will fstrim do its thing as is? I'm just checking because
there is so much contradicting information available online. Some people
mentioned that a "discard" parameter should be added to /etc/crypttab
entry, others claim they must be present on both files - fstab and
crypttab. Some even suggest to add an "allow-discards" parameter to the
GRUB kernel command line in /etc/default/grub file. I was also told that
the continuous TRIM is discouraged and that periodic should be used instead.

What's the correct thing to do here?

Thanks in advance.
_______________________________________________
dm-crypt mailing list
dm-crypt@saout.de
https://www.saout.de/mailman/listinfo/dm-crypt

             reply	other threads:[~2020-12-20 11:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20 11:36 Mistave [this message]
2020-12-20 18:12 ` [dm-crypt] Properly enabling TRIM for dm-crypt on an SSD Martin Jørgensen
2020-12-21 16:53   ` Mistave
2020-12-21 21:45     ` Mistave

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1e91347d-24ba-a387-e148-b3dd96bf0adc@countermail.com \
    --to=mistave@countermail.com \
    --cc=dm-crypt@saout.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.