Ubuntu – fstrim does not work for ext4 as root

ext4

I have a SanDisk SSD P4 32GB and I use ext4. Ubuntu 14.04.

I read that I should execute the trim command from time to time, however, this command doesn't work on my machine:

# LANGUAGE=en_US:en fstrim /
fstrim: /: FITRIM ioctl failed: Operation not supported

I already have discard mount option, but my other computer with OpenSUSE took 30 minutes when asked to fstrim for the first time, suggesting discard option did not function since installation 6 months ago. I intend to trim my Ubuntu machine too to see whether discard worked.

I googled for 30 minutes. All "answers" either say you should upgrade to ext4 or you should use root and OP says "Oh it then works thanks.". I already did both.

Best Answer

If you are using LVM and/or LUKS, then you need to:

  • add the discard option in your /etc/crypttab and /etc/fstab
  • ensure that issue_discards = 1 is set in your /etc/lvm/lvm.conf
  • rebuild your initramfs
  • then reboot

(source)

Related Question