Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
xterm -hold -e fstrim -v /
Machine:
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.
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?
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.
Yes, this was not done and I suspect is why I cannot open some of the cron folders. I still do not understand how to edit in vim. There is a ghost entry from testing with KDE's Task Scheduler which I prefer to remove. The entry is not active--I grepped it and checked the cron folders for the entry. It was set for every minute to see if it worked, and it is apparent nothing is happening (at least to me).
Quote:
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?
1. Ext4
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
I think I know where you are going. I saw something that erases useless data but I did not understand it.
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.
As of 11.4, fstrim is part of the linux-util package and is the recommended choice for invoking trim for most users......To use the kernel realtime discard feature, you must mount with the "mount -o discard" option. openSUSE will not automatically set this option, so you must either mount the partition manually or update your /etc/fstab file to do so.
The kernel implementation of realtime trim in 11.2, 11.3, and 11.4 is not optimized. The spec. calls for trim supporting a vectorized list of trim ranges, but as of 2.6.39 trim is only invoked by the kernel with a single discard / trim range and with current late 2010 SSDs this has proven to cause a performance degradation instead of a performance increase. There are few reasons to use the kernels realtime discard support with pre 3.0.0 kernels. It is not known when the kernels discard functionality will be optimized to work beneficially with current generation SSDs.
The OCZ Vertex model I have is not a 2010 model but I plan on obtaining a RevoDrive when I can afford it. So I can use mount -0 discard now and appears to be the easiest solution. I saw mention that trimming the swap partition is not advised. This is irrelevant to my situation because of the 4GB RAM present (at least for now).
This is good. I was just in the man page for fstab (as I should have been) and it gives:
Quote:
use default options: rw, suid, dev, exec, auto, nouser, and async
I see that you want to modify the options for /. I am wondering why the defaults are kept for home/ and not /
man mount (8) gives:
Quote:
discard/nodiscard
Controls whether ext4 should issue discard/TRIM commands to the underlying block device
when blocks are freed. This is useful for SSD devices and sparse/thinly-provisioned
LUNs, but it is off by default until sufficient testing has been done.
I see that you want to modify the options for /. I am wondering why the defaults are kept for home/ and not /
Sorry, but I don't understand that sentence. I simply have added the discard options to all partitions on that SSD, except the swap-partition. All other options are as given by you, I didn't modify them.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.