From e2370fec350ae8c40ad3c2ee97fe02468ee0ae93 Mon Sep 17 00:00:00 2001 From: Darrell LaRiviere Date: Wed, 19 May 2021 16:14:35 -0700 Subject: [PATCH] ssd.md: Implemented fstrim in a more general manner. Added instructions to TRIM on system start or shutdown. --- src/config/ssd.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/config/ssd.md b/src/config/ssd.md index 5b7aec0f8..bcf3d6794 100644 --- a/src/config/ssd.md +++ b/src/config/ssd.md @@ -13,15 +13,18 @@ solid state drive partition does not show TRIM support, please verify that you chose a file system with TRIM support (ext4, Btrfs, F2FS, etc.). Note that F2FS requires kernel 4.19 or above to support TRIM. -To run TRIM one-shot, you can run -[`fstrim(8)`](https://man.voidlinux.org/fstrim.8) manually. For example, if your -/ directory is on an SSD: +To run TRIM once, you can run [fstrim(8)](https://man.voidlinux.org/fstrim.8) +manually. For example, to trim all mounted filesystems mentioned in `/etc/fstab` +on devices that support the discard operation: ``` -# fstrim / +# fstrim --fstab ``` To automate running TRIM, use cron or add the `discard` option to `/etc/fstab`. +Note: using `discard` is not recommended. The `discard` method might cause the +system to slow down because it forces the system to apply TRIM instantly on +every individual file deletion. ## Periodic TRIM with cron @@ -30,7 +33,7 @@ Add the following lines to `/etc/cron.daily/fstrim`: ``` #!/bin/sh -fstrim / +fstrim --fstab ``` Finally, make the script executable: @@ -39,6 +42,14 @@ Finally, make the script executable: # chmod u+x /etc/cron.daily/fstrim ``` +## TRIM on system start or system shutdown + +Append the following line to `/etc/rc.local` or `/etc/rc.shutdown`: + +``` +fstrim --fstab +``` + ## Continuous TRIM with fstab discard You can use either continuous or periodic TRIM, but usage of continuous TRIM is