Results 1 to 5 of 5

Thread: fstrim command and LUKS ?

  1. #1

    Question fstrim command and LUKS ?

    Hi there,
    I have to admit, never cared much or read about fstrim and SSDs....

    I have / on a LUKS encrypted nvme device. /home/ is on a mechanical hdd.

    So I thought the root system / could be used with fstrim.

    Now I tried to use fstrim with --dry-run just to see what fstrim would do.

    Code:
    # fstrim -A -v --dry-run
    /mnt/windows: 0 B (dry run) trimmed on /dev/nvme0n1p3
    /boot/efi: 0 B (dry run) trimmed on /dev/nvme0n1p1
    /boot: 0 B (dry run) trimmed on /dev/nvme0n1p4
    As you can see, fstrim does not touch the root file system / it completely skipped /

    This makes me wonder, does fstrim automatically skip LUKS devices?
    Should LUKS encrypted SSD (nvme in my case) not get trimmed?

    One other thing that caught my eyes is, that systemd fstrim.timer is disabled on my system, I never touched fstrim.timer.

    How do you handle your LUKS SSDs? Do you trim?

  2. #2
    Join Date
    Sep 2012
    Posts
    6,770

    Default Re: fstrim command and LUKS ?

    Quote Originally Posted by pinguin74 View Post
    does fstrim automatically skip LUKS devices?
    Discard is disabled by default on LUKS devices; you need to open it with --allow-discard option or used "discard" option in /etc/crypttab.

  3. #3

    Default Re: fstrim command and LUKS ?

    Quote Originally Posted by arvidjaar View Post
    Discard is disabled by default on LUKS devices; you need to open it with --allow-discard option or used "discard" option in /etc/crypttab.
    Does discard need only be set in crypttab or in fstab as well?

  4. #4
    Join Date
    Sep 2012
    Posts
    6,770

    Default Re: fstrim command and LUKS ?

    Quote Originally Posted by pinguin74 View Post
    Does discard need only be set in crypttab or in fstab as well?
    "discard" in crypttab enables discard processing on device. "discard" in fstab tells filesystem to perform them automatically (if supported by filesystem). Without the former no discards are possible, neither automatic nor manual. Whether you want the latter is entirely up to you. I think automatic discards are redundant and doing them periodically makes more sense (assuming you actually need discards at all).

  5. #5

    Default Re: fstrim command and LUKS ?

    My only concern for using discard at all is SSD/NVME life expectancy, I read it should improve it.

    I guess trimming in a mechanical hard drive is not necessary at all?

    When doing lsblk --discard I was surprised to see, trimming is also available to the mechanical HDD.... But if I understand discard correctly, it makes no sense in a mechanical hdd.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •