You deleted a 50GB file and the drive feels slow
You installed Fedora on a new NVMe drive six months ago. You just archived a massive dataset and deleted 50GB of video files. You check df -h and the space is back, but your laptop feels sluggish when you start writing new files. You read a forum thread about "write amplification" and "SSD wear," and now you are worried the drive is degrading. You want to make sure Fedora is telling the drive which blocks are free so it can clean them up in the background.
TRIM is the mechanism that keeps SSDs fast. Fedora enables it by default, but verifying the configuration takes two minutes and saves you from performance surprises later.
What TRIM actually does
Solid-state drives cannot overwrite data directly. Flash memory cells must be erased before they can be rewritten. Erasing happens at the block level, which is much larger than the page level where data is written. If the drive does not know which blocks contain deleted data, it must read the entire block, merge the new data with the old valid data, erase the block, and write everything back. This process is called write amplification. It slows down writes and wears out the flash cells faster.
TRIM solves this problem. When you delete a file, the filesystem marks the blocks as free. The TRIM command tells the SSD controller exactly which blocks are no longer in use. The controller can then erase those blocks during idle time. When you write new data, the drive finds pre-erased blocks and writes immediately.
Think of TRIM like a janitor in a library. Without TRIM, the janitor has to check every shelf to find empty spots before placing a new book. With TRIM, the librarian hands the janitor a list of empty spots. The janitor cleans those spots at night. The next day, the librarian places books instantly.
Fedora uses the fstrim utility to send TRIM commands. The standard approach is a weekly timer that runs fstrim on all mounted filesystems. This balances performance and maintenance. Running TRIM on every write adds overhead. Running it once a week keeps the drive clean without taxing the controller during your work.
TRIM is a background janitor. Let it work, and your drive stays fast.
Check and enable the weekly timer
Most Fedora installations ship with fstrim.timer active. The installer enables it for ext4 and btrfs on NVMe and SATA SSDs. You should verify the status to confirm the timer is running.
Here's how to check whether the weekly trim timer is active and waiting for its next trigger.
systemctl status fstrim.timer
# Check the state of the fstrim timer
# Look for "Active: active (waiting)" in the output
# If the timer is inactive, the weekly trim will not run automatically
If the output shows Active: active (waiting), the timer is working. The system will run fstrim once a week. If the output shows inactive or dead, enable the timer.
Here's how to enable the timer to start on boot and trigger it immediately.
sudo systemctl enable --now fstrim.timer
# Enable the timer to persist across reboots
# The --now flag starts the service immediately without waiting for the weekly schedule
# This ensures you get a trim cycle right away after enabling
Enable the timer once. Fedora handles the rest.
Run a manual trim
The weekly timer covers routine maintenance. You may want to run a manual trim after deleting a large amount of data. This is useful if you just wiped a VM image, cleared a download cache, or archived a project. A manual run reclaims the blocks immediately instead of waiting for the next scheduled cycle.
Here's how to run trim manually on the root filesystem with verbose output.
sudo fstrim -v /
# Run fstrim on the root mount point
# The -v flag prints the number of bytes trimmed
# This confirms the command executed and shows how much space was reclaimed
The output will show something like / : 50.0 GiB (53687091200 bytes) trimmed. If the number matches the amount of free space you expect, the trim worked. You can run this on other mount points like /home if they are separate partitions.
Run fstrim -v / manually after massive deletions. The timer catches the rest.
Verify the trim reached the hardware
Running fstrim does not guarantee the command reached the drive. The command can fail silently if the filesystem does not support discard, or if a layer in the stack blocks the operation. You should check the logs to confirm the trim succeeded.
Here's how to check the journal for the most recent fstrim service execution.
journalctl -u fstrim.service -n 10
# Show the last 10 log lines from the fstrim service
# This confirms the trim operation completed successfully
# Look for "Trim completed" or byte counts in the output
If you see errors, the output will indicate the problem. A successful run logs the bytes trimmed per mount point. If you do not see recent entries, the timer may not have triggered yet. You can force a run with sudo systemctl start fstrim.service and check the logs again.
Check the logs. If the bytes trimmed match your free space, the command worked.
LVM, LUKS, and the discard stack
TRIM works through stacked devices. If you use LVM or LUKS encryption, the discard command must pass through each layer to reach the physical drive. Fedora configures these layers to support discard by default, but verifying the stack prevents surprises.
LVM logical volumes must be configured to issue discards to the physical volume. Fedora enables this in /etc/lvm/lvm.conf. You can verify the setting per volume.
Here's how to check if logical volumes are configured to pass discard commands to the physical volume.
lvs -o+discard
# List logical volumes with the discard column
# Fedora enables this by default, so you should see "yes" in the output
# If you see "no", LVM will block TRIM commands from reaching the drive
If discard shows no, edit /etc/lvm/lvm.conf and set issue_discards = 1 in the devices section. Then run sudo lvmchange --discards passdown to apply the change. This is rare on fresh Fedora installs.
LUKS encrypted volumes also support discard. The fstrim command sends the discard down through the LUKS device mapper. You do not need to add discard to /etc/crypttab for periodic trimming. The fstrim utility handles the communication with the LUKS layer automatically. Adding discard to the mount options is unnecessary and can cause performance issues.
Trust the stack. Modern Fedora passes discards through LVM and LUKS automatically.
Common pitfalls and errors
The most common mistake is adding discard to /etc/fstab. Some guides recommend mounting filesystems with the discard option to enable continuous TRIM. This sends a TRIM command for every deleted block. On busy systems, this creates thousands of small TRIM operations that fragment the SSD's internal workload. The result is higher write latency and reduced performance.
Here's what the fstab entry looks like when someone adds the discard option incorrectly.
/dev/sda2 /home ext4 defaults,discard 0 2
# This line enables continuous TRIM on every write operation
# The discard mount option forces the kernel to send TRIM commands immediately
# This approach degrades write performance and is not recommended for desktop use
Remove discard from /etc/fstab if you see it. Rely on fstrim.timer instead. The timer batches TRIM operations and runs them during idle periods. This is safer and faster.
Another error occurs when TRIM is not supported by the underlying device. Virtual machines often use virtual disks that do not support passthrough. If you run fstrim on a VM disk without discard support, you get an error.
Here's the error message when the filesystem or device does not support TRIM.
fstrim: /: the discard operation is not supported
# This error appears when the underlying device or filesystem does not support TRIM
# Common causes include virtual machine disks without passthrough or older hardware
# Check your hypervisor settings to enable discard passthrough if needed
If you see this error on a physical machine, the drive firmware may not support TRIM. Check the drive specifications. If you are in a VM, configure the virtual disk to support discard in your hypervisor settings.
Never add discard to /etc/fstab. The timer is safer and faster.
When to use each approach
TRIM configuration involves trade-offs between automation, performance, and immediate reclamation. Choose the method that matches your workload.
Use fstrim.timer when you want automatic weekly maintenance with minimal performance impact. This is the default for Fedora Workstation and Server. It keeps the drive clean without interfering with your work.
Run fstrim -v / manually when you just deleted a massive dataset and want to reclaim space immediately. This is useful after archiving projects, wiping VM images, or clearing large caches. The timer will catch the next cycle, but a manual run gives you instant feedback.
Use the discard mount option only when you are running a specific workload that requires immediate block reclamation and you accept the write performance penalty. This is rare. Most users should avoid this option.
Skip TRIM configuration when you are running Fedora inside a virtual machine with a virtual disk that does not support passthrough. Enabling TRIM on unsupported disks causes errors and wastes cycles. Verify hypervisor settings first.