TRIM4SSD-noarch
'Kay, boys & girls. I have a new, built-from-scratch utility for those of you running SSDs as your storage instead of HDDs.
I decided to 'splurge' a week or so ago, and treated myself to a 1TB Crucial MX500 SSD as the primary drive for my relatively new HP Pavilion tower. Nowt wrong with the existing 1TB Toshiba HDD, but the Crucial was available for a reasonable price on Amazon, so I decided to grab one while they were still available...
As you're probably aware, SSDs need regular 'cleaning' - known as 'trimming' - or, in native parlance, 'garbage collection'. This is all due to the way in which SSDs, unlike the way that HDDs work, have to erase each data 'block' before anything new can be written to that block again. During this process, the controller also performs what's known as 'wear-levelling'.....moving the blocks of data around so that each block gets written to the same number of times. Etc, etc....
There's also what's called the 'rule of 10'. By this, I mean the general advice given to leave around 10% of an SSD unformatted; this makes the controller's job a lot easier, as it gives it an 'empty' area - unencumbered by filesystem overheads - in which to juggle the blocks around as they get erased, then marked as fit for re-use again.
There IS a Linux utility, known as fstrim, that will automate this 'cleanup' procedure. It's part of the 'util-linux' package that is available from the repos of every major distro out there (it's one of those universal packages available across the entire eco-system). Fstrim basically automates this entire cleanup process at one go. According to the 'fount of all Linux knowledge' - the Arch Linux wiki - this only needs performing once a week or so.
So....
------------------------------
Normally, this is performed as a regular cron-job by systemd. Puppies don't use systemd; it's one thing that's almost universally despised by Puppians, since for one thing it doesn't like letting the user run as root.....this being a defining characteristic of every Puppy ever built. Puppy has its own 'scheduler' - pSchedule - that will permit setting up regular cron-jobs - but I wanted something that would let the user run the 'trim' command manually, as & when desired.
So; I've built 'TRIM4SSD', both as a 'portable' application, and as a .pet package for those that prefer these.
A small YAD-powered GUI appears when launched.....like this:-
File-systems/partitions need to be mounted for this to work, and preferably should be trimmed 'off-line', i.e., from a Puppy on a different partition to the one that you wish to 'trim'. The "Mount" & "Unmount" buttons bring up drop-down selectors, permitting the mounting/unmounting of up to a dozen pre-set partitions. Mount before operation, unmount when finished.
When your partitions have been selected, hit the 'TRIM NOW' button. A wee rxvt terminal window will appear, showing the progress of the fstrim command's output; do be aware that if you haven't 'trimmed' the partition/drive in question for some time, it may take a while before a read-out appears.....this is perfectly normal, since fstrim only displays the finished result.
When the terminal window shows that the chosen partitions have been 'trimmed', you can close the window. Then, unmount your partitions, and finally, you can close the utility. Simples!
-------------------------------------
The 'portable' is in this instance a RoxApp - ROX-filer's native 'portable' format. Just click on the thing, and it immediately launches. The .pet package installs a modified version of the portable to /opt, along with a link to /usr/bin and a .desktop file in /usr/share/applications for a standard MenuEntry under Menu->System.
These are 'no-arch' packages - architecture-independent - since there's no binaries involved. Both are zipped, together with a 'ReadMe!' file, into a standard tarball. When unzipping, please read the ReadMe! file before doing anything else; it contains important information, without which the utility will not perform as intended. I can't supply the necessary 'util-linux' components, since these are different for every single Puppy, but they will be available from the PPM. It will work in 32-bit Pups as well as 64-bit Pups, since it's dependent on the 'util-linux' package from the repos.
As-is, it works OOTB for the Xenialups, the Bionicpups and the Fossapups. Further back, we run into issues; the fstrim binary for the Tahrpups was a very early implementation, missing some of the options needed for this to function; SSDs were in their early days back then, 7-8 years ago, and also somewhat fragile & temperemental, too.
Accordingly, I've built a 'compatibility' package for the Tahrs and also some older Puppies.....5/6-series Slackos, for instance. This uses a self-contained directory in /usr/lib, containing the fstrim binary & libmount dependency from Xenialpup, along with a launcher script in /sbin which calls the alternative fstrim's libmount dependency via an 'LD_LIBRARY_PATH' clause. It seems to work quite nicely. You may also need to update the YAD package in an older Puppy to a recent one, say 0.38.0 or 0.40.0, since older Puppies came with an ancient version of YAD by default. These usually update without issue, and don't generally create any problems.
-----------------------------------------------
You can find all components - portable, .pet, compatibility packages & updated YAD packages - at my MEGA.nz a/c, here:-
https://mega.nz/folder/TT43jSKA#9pLKABeqDDEYg3R5wWnl0A
Hope some of you will find these useful! Enjoy.
Mike.
Edited by Mike_Walsh, 13 January 2022 - 08:38 PM.