LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Would this be a valid script for fstrim in rc.6? (https://www.linuxquestions.org/questions/slackware-14/would-this-be-a-valid-script-for-fstrim-in-rc-6-a-4175538926/)

tobyl 04-06-2015 12:41 PM

Would this be a valid script for fstrim in rc.6?
 
Hi,

Anyone care to venture an opinion on the following? I recently put an msata solid state drive in my laptop. As far as I am aware, Slackware does nothing out of the box to manage TRIM etc on this type of drive.

I came across the following script:
"The following script can be used to automatically detect and fstrim all filesystems that have TRIM support enabled."

Code:

#!/bin/sh
#
# To find which FS support trim, we check that DISC-MAX (discard max bytes)
# is great than zero. Check discard_max_bytes documentation at
# https://www.kernel.org/doc/Documentation/block/queue-sysfs.txt
#
for fs in $(lsblk -o MOUNTPOINT,DISC-MAX,FSTYPE | grep -E '^/.* [1-9]+.* ' | awk '{print $1}'); do
        fstrim "$fs"
done

This script assuming it does as advertised, would suit rc.6 on machines that are shutdown, probably better as a cron job on an always up box. Possibly even a candidate for inclusion in rc.6 as standard?

For reasons explained here:
http://blog.neutrino.es/2013/howto-p...m-and-dmcrypt/

it seems a better option than the discard parameter in fstab.

regards,
tobyl

TracyTiger 04-06-2015 01:29 PM

I ran the script (except the fstrim program) on the machine I'm at now and it produced.

Code:

/boot
/
/vboxdata
/home
/boot
/
/vboxdata
/home

The duplicates are because there are two SSDs in a RAID configuration.

I'm not a fan of your idea. I prefer configuring the machine manually as appropriate (discard option) rather than hoping a script understands the configuration correctly.

You probably don't want the programs being run (lsblk, fstrim) to change with the environment ($PATH). /bin/lsblk and /sbin/fstrim would be better.

Just my thoughts. It's good to think up and try new items that "may" improve the system whether they are successful/accepted or not.

tobyl 04-07-2015 11:58 AM

Thanks for replying Tracytiger

You raise fair points.
I think the script could be adjusted to fix the path to point direct to the binaries, on reflection this does seem to be the normal way of doing stuff in rc files.
If it couldn't be improved to take care of special cases such as raid arrays (which I doubt is beyond the wit of man), it could just be an optional section commented out unless the user decided to activate it, in a similar way to the S.M.A.R.T disk monitoring in rc.M

I just thought in these days where ssd drives are commonplace, it might be worthy of consideration.

tobyl


All times are GMT -5. The time now is 12:50 AM.