Modern Solid State Drives (SSDs) and NVMe storage devices require a maintenance operation called TRIM to maintain optimal write speeds and longevity. TRIM informs the SSD controller which data blocks are no longer considered in use by the file system, allowing the drive to wipe them internally and prepare them for new data. In Ubuntu Server, this operation is not performed continuously; instead, a systemd timer (fstrim.timer) wakes up once a week to execute the fstrim command across all mounted file systems. While highly recommended for bare-metal hardware, scheduled TRIM operations can cause severe I/O spikes and performance degradation in certain virtualized environments, SAN-backed storage arrays, or specific software RAID configurations where the hypervisor or storage controller prefers to handle block management natively.
This guide explains how to completely disable the weekly fstrim timer in Ubuntu Server.
Disable the fstrim Timer via Systemctl
The TRIM operation is managed entirely by systemd’s timer infrastructure. To stop Ubuntu from issuing TRIM commands, you must stop the timer and disable it from starting upon the next reboot. We will also mask it to prevent other services from accidentally triggering it.
- Log into your Ubuntu Server via SSH or a local console terminal.
- First, check the current status of the timer to confirm it is active.
systemctl status fstrim.timer - Stop the timer immediately to ensure it does not run in the background:
sudo systemctl stop fstrim.timer - Disable the timer so it will not automatically load during the boot sequence:
sudo systemctl disable fstrim.timer - Mask the timer to completely paralyze it, linking its configuration to
/dev/null. This guarantees that no other system process or administrator can accidentally start it without explicitly unmasking it first:sudo systemctl mask fstrim.timer
Verify the Timer is Disabled
To mathematically verify that the system will no longer attempt to execute scheduled TRIM operations, you can list all active and inactive systemd timers using the following command:
systemctl list-timers --all | grep fstrim
Because the timer has been masked, this command will return completely blank output. Your Ubuntu Server will now rely entirely on the underlying hypervisor, SAN controller, or physical drive firmware to manage block reallocation and garbage collection.