I noticed that fstrim wasn’t working on my new Ubuntu 24.04 desktop installation, failing with “fstrim: /: the discard operation is not supported”. In that setup, Ubuntu is installed into an LUKS encrypted LVM volume, so the ext4 file system, LVM and LUKS need to play nicely together for flash discard to work.
That’s how I got it working:
- sudo su
- Edit /etc/fstab, find where the root volume is mounted (for me that was something like /dev/disk/by-id/dm-uuid-LVM-xyz) and change the mount options to “defaults,discard,errors=remount-ro”
- Edit /etc/crypttab and add “,discards” to the options. For me, after editing, the options were “luks,discard”
- update-initramfs -c -k all
- Reboot
After rebooting, “fstrim -v /” should show that discard worked and “dmsetup table” should show an “allow_discard” flag for the device.
Resources
fstrim man page
https://man7.org/linux/man-pages/man8/fstrim.8.html
Ubuntu on the Acer Nitro N15
https://blog.georgovassilis.com/2025/05/26/ubuntu-on-the-acer-nitro-anv15-41/
Linux Unified Key Setup
https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup
Logical Volume Manager
https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)