Help with creating a startup shell script to run update & fstrim on startup

Additionally:

Is Fstrim Still Necessary for SSDs

Running the fstrim command on SSDs in Linux is still beneficial for maintaining optimal performance and extending the lifespan of the SSD. Modern Linux distributions, such as Ubuntu and Fedora, typically have fstrim scheduled to run automatically on a weekly basis via a systemd timer or cron job. This automation helps ensure that unused blocks are discarded regularly, which can improve write performance and wear leveling.

However, it’s important to verify that your SSD and filesystem support TRIM. You can check if TRIM is enabled by running:

sudo hdparm -I /dev/sda | grep TRIM

If your system is already set up to handle TRIM operations automatically, manually running fstrim might be redundant. Additionally, ensure that you’re not running fstrim during intensive operations, as this could impact performance.

In summary, while fstrim is still necessary for SSD optimization, many modern Linux distributions handle it automatically. If your distribution does not have fstrim enabled by default, you can enable it using:

sudo systemctl enable --now fstrim.timer
5 Likes