:: Re: [DNG] SSD and trim service
Kezdőlap
Delete this message
Reply to this message
Szerző: al3xu5
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] SSD and trim service
Thu, 17 Nov 2022 19:06:26 +0100 - Rand Pritelrohm via Dng
<dng@???>:

> I plan to migrate to Devuan, and getting rid of systemd.


Very nice!

> For now most of my configuration is done.
>
> But I still need to tweak the management of my SSD disk, so I need to
> find:
>    i) a 'trimming' service



Here below the script I use to automate periodic (weekly) TRIM, with
logging and log rotation:

1. create a directory for logs:

    $ sudo mkdir /var/log/fstrim


2. edit cronjob (here I am using nano text editor):

    $ sudo nano /etc/cron.weekly/fstrim


/etc/cron.weekly/fstrim content:

#!/bin/bash
#
# TRIM for SSD disks, with logging
# Run fstrim on ALL disk partitions, logging results.
#
LOGDIR=/var/log/fstrim
LOGFILE=$LOGDIR/fstrim.log
if [[ ! -d $LOGDIR ]] ; then mkdir $LOGDIR ; fi
echo "** $(date -R)" >> $LOGFILE
fstrim -v -a >> $LOGFILE

4. set permissions:

    $ sudo chmod a+x /etc/cron.weekly/fstrim


5. edit log rotation (here I am using nano text editor):

    $sudo nano /etc/logrotate.d/fstrim


/etc/logrotate.d/fstrim content:

/var/log/fstrim/fstrim.log {
    monthly
        missingok
        rotate 3
        nocompress
        nomail
        noolddir
        noshred
}


6. Reboot (or restart log services)

This should have enabled the cronjob to be run at system boot by `anacron`
(with root privileges) every week.

Regards
al3xu5

--
Say NO to copyright, patents, trademarks and industrial design
restrictions!
____________________________________________________________________________

Public GPG/PGP key: 8FC2 3121 2803 86E9 F7D8 B624 DA50 835B 2624 A36B