Ubuntu – fstrim does not work

ssdtrim

I have a Thinkpad X60s with an OSZ agility SSD. I use ext2.

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

boris@boris-ThinkPad-X60s:~$ fstrim /
fstrim: /: FITRIM ioctl failed: Inappropriate ioctl for device

What will be the consequences of me not using it? Will it affect speed, SSD life etc?

Why isn't the command working and what are the possible solutions to get it working?

Best Answer

Update: I wrote the answer below before seeing you were using ext2. I keep the answer for reference in case anyone else has a similar problem because of LUKS or LVM.

For your case however the anser is different: ext2 does not support trimming, only ext4 or btrfs do.

----- original answer -----

Make sure to activate trim support on all filesystem abstraction layers. In particular, LVM and / or dm-crypt come to mind here!

  1. Activate trim support in lvm: /etc/lvm/lvm.conf

    issue_discards = 1
    
  2. Activate trim support in dm-crypt/luks: /etc/crypttab

    sda1_crypt UUID=<YOUR_DISKS_UUID> none luks,**discard**
    

    (adapt to your UUID and partition)

  3. write changes to your initrd:

    sudo update-initramfs -u
    
  4. reboot