LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-06-2015, 12:41 PM   #1
tobyl
Member
 
Registered: Apr 2003
Location: uk
Distribution: slackware current
Posts: 768

Rep: Reputation: 64
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
 
Old 04-06-2015, 01:29 PM   #2
TracyTiger
Member
 
Registered: Apr 2011
Location: California, USA
Distribution: Slackware
Posts: 528

Rep: Reputation: 273Reputation: 273Reputation: 273
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.

Last edited by TracyTiger; 04-06-2015 at 01:31 PM.
 
1 members found this post helpful.
Old 04-07-2015, 11:58 AM   #3
tobyl
Member
 
Registered: Apr 2003
Location: uk
Distribution: slackware current
Posts: 768

Original Poster
Rep: Reputation: 64
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
 
  


Reply

Tags
fstrim


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Running fstrim manually on a swap partition - can it be done? flokofcgulls Slackware 3 05-31-2013 11:58 AM
script for searching valid users? Crimsonlegion Linux - General 1 12-05-2012 05:56 PM
Shell script doesn't think a directory is valid (but it is) ssrobins Linux - General 4 04-21-2010 09:23 PM
How to make script cmd valid as execut it directly? cdcshu Linux - Software 5 06-05-2007 05:58 AM
"unable to read a valid proxy configuration script" adish kandalgaonkar Linux - Networking 1 05-20-2007 05:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration