SSD Trim simple bash script program
Hi folks, I wrote this script which works but it should run automatically about once per week.
I hunted and experimented with KDE Task Scheduler (no dice and no help anywhere) and cron (confusing instructions and cannot edit crontab -e with vim, and cannot enter cron folders/files). I would settle for a desktop shortcut to run the script but found no help for that. Script: Code:
#!/bin/bash OS: openSUSE 11.4 x86_64 Kernel: Linux 2.6.37.6-0.5-desktop Desktop: KDE 4.6.00 rel 6 Machine: HP xw9400 AMD 64 Opteron Chipset: nVidia nForce Pro 3600 and 3050 (proprietary Tyan Thunder) Drive: OCZ Vertex 60 GB dedicated system--single boot RAM: 4 GB ECC Video: nVidia GT200 (GeForce 210) 512 MB 2D Driver: nouveau 3D Driver: swarst (no 3D acceleration) (7.10) Audio: Creative Titanium Fatal1ty Pro Driver: ALSA (No-frills. Must use open source controls) I am not asking anyone to write code, I could use some pointers, though. Thanks. |
cron would be the easiest. You should add your average, everyday user to the cron group to gain access to the necessary directories. Set EDITOR to vim and you will be able to edit crontabs with vim.
|
I have some questions:
1. Which file-system do you use and what mount-options do you have for the partitions on your SSD? 2. Does the SSD have native TRIM support in its firmware? |
Quote:
Quote:
Mount options: Default Mount by Device ID 2. Yes the drive has trim support. Here is the output of my script: Code:
/: 16767717376 bytes was trimmed Thanks for the input everyone. |
If you use ext4 and your device has TRIM support you don't need your script to do the trimming. Just add the mount-option discard in your /etc/fstab to the partitions on the SSD. Now every-time a sync-command is launched (which is at least every shutdown/reboot) your partitions will automatically be trimmed.
You don't need to use vim for editing the crontab, you can use your favorite editor for that. Have a look at the crontab-command for learning how to make use of cron. |
Okay. This is what openSUSE recommends:
Quote:
Here is the fstab file: Code:
/dev/disk/by-id/ata-OCZ-VERTEX_MG05KW6J9686Z397B4P1-part1 swap swap defaults 0 0 |
Simply add it after the other options, in your case that it looks like
Code:
/dev/disk/by-id/ata-OCZ-VERTEX_MG05KW6J9686Z397B4P1-part2 / ext4 acl,user_xattr,discard 1 1 |
This is good. I was just in the man page for fstab (as I should have been) and it gives:
Quote:
man mount (8) gives: Quote:
|
Quote:
|
Sorry, I got confused. Ok, I will run with this. No news is good news; otherwise I will report back.
Thank you. |
There was a false alarm with the last IFL backup. The backup image failure was a fluke (the disk is a little beat up).
So it appears adding Code:
,discard If an application would benefit from more frequent trims, then cron is the way to go. One question, however. The script command I have is Code:
xterm -hold -e fstrim -v / Code:
/ There are two in fstab (disregarding swap, which should researched further). In fact, the question which partition needs trimming has not been definitively answered AFAIK. |
All partitions on that SSD should need trimming, so I would do it for /home also.
If you do trimming with your script in crontab I wouldn't use xterm for that, unless you want that this window pops up every time cron trims the SSD. |
Here's a reasonable guide to crontabs http://adminschoice.com/crontab-quic...Crontab%20file
|
Thanks. The more the better.
|
All times are GMT -5. The time now is 09:36 PM. |