fstrim-all
Trim all mounted file systems on SSDs
SYNOPSIS
fstrim-all
DESCRIPTION
The fstrim-all command is a utility designed to efficiently discard unused blocks on mounted Solid State Drives (SSDs) and other devices that support the TRIM operation. It iterates through all mounted filesystems and executes the fstrim command on each, sending the TRIM command which informs the underlying storage device about blocks that are no longer in use. This allows the device to reclaim those blocks, improving performance, extending lifespan, and potentially reducing write amplification. Regularly running fstrim-all, often via a cron job or systemd timer, helps maintain optimal SSD performance over time.
This command essentially automates the process of manually running fstrim on each mounted filesystem, simplifying SSD maintenance on Linux systems. It is crucial for optimal SSD performance, particularly when dealing with filesystems that do not support online discard (mount option 'discard'). Without regular TRIM operations, SSD performance can degrade significantly over time as the drive struggles to efficiently manage its available space. The script considers and handles scenarios where certain filesystems might be unsupported or inaccessible by a regular user, elevating privileges with sudo if necessary.
CAVEATS
Requires root privileges if any mounted filesystem isn't user accessible. May not function as expected on RAID configurations or virtualized storage without TRIM support.
EXECUTION & PRIVILEGES
The command typically needs to be run as root, or with sudo privileges, to access and trim all mounted filesystems. It checks if it can trim all mount points as the calling user, and elevates privileges via sudo if necessary. If run without sufficient privileges, some filesystems may be skipped.
SCHEDULING
fstrim-all is commonly scheduled to run periodically (e.g., weekly or monthly) using cron or systemd timers to ensure ongoing SSD optimization.
MOUNT OPTIONS
If the 'discard' mount option is used, it enables online TRIM, meaning TRIM operations happen in real-time when files are deleted. However, not all filesystems and SSDs support online TRIM reliably, and it can potentially cause performance issues. fstrim-all can be useful even with the 'discard' mount option, as it can help to consolidate trim operations and ensure that all unused blocks are eventually reclaimed. Careful consideration of the filesystem and SSD's capabilities is recommended.
HISTORY
fstrim-all is typically implemented as a shell script, a program or a set of commands. Usage has increased with SSD adoption and the necessity for efficient disk space management. It became more relevant as modern operating systems shifted towards relying more on SSDs for performance, and the need for automated TRIM became apparent.