Page 1 of 2

TRIM4SSD-portable (now @ v1.5) - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Mon Jan 10, 2022 12:45 am
by mikewalsh

Now then, kiddiwinks...

Having "splurged" the other day, and treated myself to a 1TB Crucial MX500 SSD as a primary drive replacement, it then occurred to me that what was needed was a way to manually run the 'TRIM' command, which tells the controller to run through its garbage-collection routine & tidy things up. Without this, you eventually end up with a highly 'messy' solid state drive.

https://forum.puppylinux.com/viewtopic. ... 625#p46625

I've followed the standard advice, and left around 10% of the drive - approx 100 GB - unformatted. The thinking here is that this gives the controller room to juggle blocks around as it runs through the erase routine & marks the blocks as fit for re-use again. However, it definitely helps if you can run the official

Code: Select all

fstrim

.....command from time to time, since this 'forces' everything through the proper, approved tidy-up routine.

-------------------------------------------

I posed the question at the end of the above post. Bigpup started a new thread to deal with this, here:-

https://forum.puppylinux.com/viewtopic.php?t=4894

I've created a wee portable - RoxApp, actually - with a YAD-powered GUI & "borrowed" a chunk of the DriveSpeed! code.....the bit that brings up the tiny rxvt terminal window to show you the result. Had to tiffle around with one or two of the options to get it behaving itself, but all you do is click on the RoxApp to bring up the GUI. You then hit the 'TRIM NOW' button, and the rxvt window pops-up to show you the result as it occurs.

The current version allows you to mount/unmount filesystems in order to run the fstrim command correctly.....partitions need to be mounted for it to work properly.

You WILL need to install the

Code: Select all

util-linux

.....package from your PPM. I can't include this because it's all different for every single Puppy, and includes a bunch of file-system/mount-point/disk-management tools, all of which are of course compiled to work with specific kernel/glibc set-ups. But having done this (apparently this is a bog-standard package across the Linux eco-system), this wee utility just lets us use the bit we need to maintain our SSDs in tip-top condition.

Image

According to the Arch Linux wiki - the fount of ALL Linux knowledge, as far as I and about a million other folks are concerned! - this only needs to be carried-out manually around once a week.....perhaps twice a week, if your machine gets extremely heavy use. I know the terminal command is simple enough to run, but the GUI is to make things just a little easier for our 'noobs'.....and you still need the 'util-linux' package installed for the terminal command to work in any case. Most PPMs will tell you its already installed, but will 're-install' without any protests.

IF you wish to add a Menu entry, 'Look Inside' with ROX and you'll find the MenuAdd/Remove scripts. The 'MenuReadMe' will explain how to use them.

------------------------------------------------------

I've attached the tarball to the bottom of this post. Just download it, unzip it, then put the RoxApp anywhere you like. Please look at the "ReadMe!" file before using it; it will give you necessary initial information.

This works OK with Xenialpup64, Bionicpup64, and Fossapup64. Tahr64's version of fstrim is a sym-link to BusyBox, and is a very early implementation, missing many of the necessary options. Since this is a 'noarch' package, it's only limited by what "util-linux" package your PPM can provide and which options are built-in.....it should work OK with newer 32-bit Puppies, too.

Hope it's perhaps useful to some of you. Enjoy.

Mike. ;)


Re: TRIM4SSD-portable - Manual 'TRIM' utility for those of you running SSDs.....

Posted: Mon Jan 10, 2022 7:06 am
by backi

That`s cool Mike! :thumbup: :thumbup:


Re: TRIM4SSD-portable - Manual 'TRIM' utility for those of you running SSDs.....

Posted: Mon Jan 10, 2022 10:17 am
by ozsouth

@mikewalsh - IIRC, ext3 partitions have to be trimmed offline; i.e. boot another
partition or device, then mount partition to be trimmed, then run fstrim -v /mnt/sd(whatever).


Re: TRIM4SSD-portable - Manual 'TRIM' utility for those of you running SSDs.....

Posted: Mon Jan 10, 2022 12:09 pm
by mikewalsh
ozsouth wrote: Mon Jan 10, 2022 10:17 am

@mikewalsh - IIRC, ext3 partitions have to be trimmed offline; i.e. boot another
partition or device, then mount partition to be trimmed, then run fstrim -v /mnt/sd(whatever).

I won't argue with you, Oz! I'm very much a neophyte when it comes to this kinda thing. I've had a couple of SSDs prior to this one, but both were MLC, with IDE/PATA interfaces, and neither supported TRIM, so.....

That was how I came across the "10%" trick. It's a way of making life easier for those SSDs that don't support the TRIM command. It also, apparently, doesn't hurt with flash drives, either, since in both cases the storage medium is NAND flash...

Mike. ;)


Re: TRIM4SSD-portable - Manual 'TRIM' utility for those of you running SSDs.....

Posted: Mon Jan 10, 2022 5:15 pm
by bigpup

Nice little program.
I put a link to this topic in the Trim how to topic.

You need to point out, that the partition on the SSD, that you are going to trim, has to first be mounted.

Example:

I have an SSD with two partitions.
One partition is mounted, because I am booting from it.
The other partition is not mounted.

When I run the trim program.
The mounted partition was trimmed.
The other partition was not,

If both partitions are mounted, before running the trim program.
Trim is done on both partitions.

Is there a way to select what SSD to trim, if you have more than one SSD?


Re: TRIM4SSD-portable - Manual 'TRIM' utility for those of you running SSDs.....

Posted: Tue Jan 11, 2022 2:04 am
by mikewalsh

@bigpup :-

That's a worthwhile addition, I think. Accordingly, here's v1.3, which now includes a wee 'mount' GUI, allowing you to select any one of up to a dozen possible partitions, prior to performing the trim operation itself. Also allows you to unmount when finished.

Information regarding the need to be mounted FIRST has been added to the "ReadME!"

Attached to post #1.

Mike. :)


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for those of you running SSDs.....

Posted: Tue Jan 11, 2022 9:27 pm
by mikewalsh

Just to confirm; Trim4SSD works fine in 32-bit Puppies, too.

I've "re-installed" the 'util-linux' package from the PPM in Xenialpup 7.5 (PPM says it's installed, but of course it isn't.) :roll: Having done that, 'fstrim' is now available - a new enough version to have the required commands for our needs here - and running TRIM4SSD-portable gives the expected results.

So; there ya go.

Mike. ;)


Re: TRIM4SSD-portable - Manual 'TRIM' utility for those of you running SSDs.....

Posted: Wed Jan 12, 2022 9:08 am
by bigpup
mikewalsh wrote: Tue Jan 11, 2022 2:04 am

@bigpup :-

That's a worthwhile addition, I think. Accordingly, here's v1.3, which now includes a wee 'mount' GUI, allowing you to select any one of up to a dozen possible partitions, prior to performing the trim operation itself. Also allows you to unmount when finished.

Mike. :)

Nice added feature (mount/unmount), but it does not work for all SSDs on my computer.

One internal SSD drive, with 3 partitions, is identified as:
nvme0n1p1
nvme0n1p2
nvme0n1p3

Had to mount it with Pmount or clicking on the desktop drive icons.

I have one SSD, has one partition, that is identified as sda2, so the moun/unmount feature works for it.

probedisk

nvme0n1 drive WDBRPG5000ANC-WRSN
sda drive ATA SanDisk SDSSDH35

I can report good trim results on both drives.
Both drives did need some trimming.


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Thu Jan 13, 2022 1:57 am
by mikewalsh

Evening, gang.

Updated version of TRIM4SSD - v1.4 - now attached to post #1. I've done a bit more work on the GUI, and the "Mount" & "Unmount" buttons now bring up partition selection via a more friendly 'drop-down' menu.

Now; to try & make this a bit more accessible, I've put together 32- and 64-bit 'compatibility' packages for older Puppies. This has come about because of older versions of 'fstrim' only having very basic options; the tech WAS in its infancy back in the days of Tahrpup and the 5/6-series Slackos, 7-8 yrs ago.

The one thing fstrim does demand is a matching version of libmount, which is hardly surprising. These packages both use the fstrim binary & libmount library from the Xenialpups; these are the oldest Pups where fstrim does what we want.....there's no point going too new with these, because you'll then start running into glibc issues on top of everything else.

Fstrim & libmount sit in their own self-contained directory in /usr/lib, together with a launcher that contains an 'LD_LIBRARY_PATH' clause to point fstrim at its matching libmount. This is all called by a launcher in /sbin, this being the usual location for the fstrim binary.

------------------------------------------------

I've tried these in the Tahrs and some older Slackos (chiefly 5-series) with a fair degree of success, so there's a good chance they'll work with the 6-series Slackos as well. More up-to-date YAD packages may be required; I can supply these if anybody wants them.

I'm attaching the 'compat' packages below. If I try to attach them to post #1, it pushes things beyond the 512Kb attachment limit. Hope they're useful for some of you.

Mike. ;)


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Thu Jan 13, 2022 10:54 am
by puppy_apprentice

I've heard that fstrim doesn't work with ext2. For ext2 (and above) partitions is special script (doesen't use fstrim):
https://github.com/Distrotech/hdparm/bl ... r/wiper.sh

There is tool that uses wiper.sh:
http://disktrim.sourceforge.net/


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Thu Jan 13, 2022 12:32 pm
by mistfire

@mikewalsh

Do you have pet package version of this app?
I noticed that block devices was hard coded. Can you make more dynamic against block devices by using probepart?


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Thu Jan 13, 2022 12:36 pm
by mikewalsh
mistfire wrote: Thu Jan 13, 2022 10:48 am

@mikewalsh

Do you have pet package version of this app?
I noticed that block devices was hard coded. Can you make more dynamic against block devices?

@mistfire :- Umm.....no, to both questions.

"Portables" are my speciality these days. If you want to turn it into a .pet package, go right ahead; feel free. As for - what was it you asked? - "make it more dynamic against block devices", huh?? I don't even know what you mean by that.

Unlike yourself.....or josejp2424.....or dimkr.....or peebee.....or01micko.....or 666philb.....etc., etc., don't ever, EVER make the mistake of thinking that I actually know what I'm doing. Frankly, I'm envious of the ease with which you guys push out code; everything I put together is at the absolute limits of my very basic Bash understanding (which is not very much!) :lol:

I'm NOT a coder; I'm a 'tinkerer', who frequently amazes himself that he manages to make anything work AT ALL. :shock:

If I get something working to the point where I'm happy enough with it to want to "share" it, then as far as I'm concerned, once I've published it, it then becomes "community property". ANYBODY is free to do with it what they like, so long as they give me credit (where it's an original idea, of course).

(Improvements to ANY of my 'efforts' are always welcome. All I ask is that you let me know what you're doing with them!)

Mike. ;)


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Thu Jan 13, 2022 1:12 pm
by mikewalsh

As requested above by @mistfire , here's a .pet package of TRIM4SSD-v1.4-noarch.....for those who don't like 'portables'.

Attached to the first post. Unzip the tarball. Please read the "ReadMe!" FIRST, as it contains information you will need BEFORE installing the .pet.

Mike. ;)


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Thu Jan 13, 2022 3:09 pm
by mistfire

@mikewalsh

Based on your script, I saw sda, sdb, etc. scripts which represents block devices. Thats why I noticed that it seems hard-coded against block devices.

It might took time to convert it to dynamic by utilizing probepart.

By the way, I have plan to include the trim4ssd on my QuickPup64 that's why I need a pet package version.

Also thanks for you tips


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Thu Jan 13, 2022 8:16 pm
by ndujoe2

Thanks I did the Trim thing, I have Bionicpup64. ppm said that the util-linux was installed but like the other other person's post, it was not. So I told it to install and everything worked fine. I guess my ssd's are not too messed up, it didn't take long 8 GB sizes.

Joe


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Fri Jan 14, 2022 12:04 am
by bigpup

Just some info to pass on to others.

I have one SSD, that has not been trimmed, for a long time.
It is 500GB.
I recently did a lot of cleaning out of stuff, on it.

When I used Trim4SSD v1.4 on it.
The pop up window, showing results.
Was empty for about 1 minute, until trim was finished.
Then it showed results.
341.4 GiB

So you get no progress indication, as it is working, only result.

If it seems to not be working, just give it some time to finish, and give results.


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Fri Jan 14, 2022 2:16 am
by mikewalsh

@bigpup :-

I was toying with the idea of implementing a 'progress bar' of some kind, but it's not really feasible given that everybody's usage is going to be different.....and therefore time taken to complete the operation is going to be infinitely variable.

Mike. :|


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Fri Jan 14, 2022 1:33 pm
by bigpup

As I said, this is info, so people do not think it is not working.

I agree with you about not having a progress bar.
Some trim operations could go very quickly.
The progress bar would not have time to even show.

Wonder if a simple statement could be placed in that output window. :idea:

Trim in progress....... Wait for results.
Or:
May take some time to trim........Wait for results.

Note:
I tried using this on a Raspberry Pi 400, running in Raspup 8.2.1
It checks the SD card, used for a drive, in these things.
It runs and gives a trim report on the SD card.
Not sure, if that really is providing anything that a SD card, needs.
But, it does show, this TRIM4SSD does seem to work, over a lot of different versions, of Puppy Linux.


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Sat Jan 15, 2022 8:01 pm
by bigpup

In the file fstrim.sh

I made this change to the rxvt -title

Code: Select all

rxvt -title 'Trim in progress....... Wait for results'

When the output window pops up.
It now looks like this:
.

Screenshot(9).jpg
Screenshot(9).jpg (11.81 KiB) Viewed 1230 times

.
.
Mikewalsh, what do you think about this change?

Also tried this change:
.

Screenshot.jpg
Screenshot.jpg (12.52 KiB) Viewed 1230 times

.
.
So, you can see a lot of info can be placed in that rxvt-title

It is your program.
Just showing some easy optional tweaking you could do.


Re: TRIM4SSD-portable v1.3 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Sat Jan 15, 2022 9:55 pm
by mikewalsh

@bigpup :-

Mm..! Oh, aye; I agree completely. That never occurred to me, TBH; there IS a lot of empty space in that title bar, which could otherwise be gainfully employed! :lol:

Yes; I'll make some alterations, mate. Cheers for pointing it out....

As we say in Yorkshire, "Ta very much, lad!"


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Mon Jan 17, 2022 8:50 pm
by bigpup

Just wondering.
Sure it is OK for you to be using an icon that is probably registered tradmark to the Sandisk company?
SanDisk®

Western Digital Trademarks under the SanDisk brand with the appropriate mark symbols under U.S. law.


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Mon Jan 17, 2022 11:18 pm
by mikewalsh

@bigpup :-

Heh. Have you ANY idea - any at all - just how hard it is to track down an 'inspiring' icon for summat like an SSD? I mean, sure; they do amazing things for your computer, but, well.............they're not exactly the most exciting things to look at, are they? :roll:

You're probably right about using the SanDisk piccie, though. I've got NO wish to be getting into copyright fights, so.....I managed to track down a half-way decent drive icon and modified it a bit. I've re-built/re-packed both packages in post #1 with this new icon; you can see it in the screenshot half-way down.....

Mike. ;)


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Tue Jan 18, 2022 10:26 am
by mistfire

@mikewalsh

I made some modifications on your trim4ssd. It is now flexible and dynamic and the gui was improved
Check the package that I sent


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Tue Jan 18, 2022 11:41 am
by mikewalsh
mistfire wrote: Tue Jan 18, 2022 10:26 am

@mikewalsh

I made some modifications on your trim4ssd. It is now flexible and dynamic and the gui was improved
Check the package that I sent

@mistfire :-

Mm! Nice. I see what you mean by "dynamic", now; rather than a 'fixed' list of partitions - that may or may not exist! - when it's dynamic, it's working with what is actually there. And I like the way the 'unmount' combobox now works.....only listing what is in fact mounted when the command is run.

-------------------------------------------------------------

With regard to your statement "The GUI was improved", that's subjective. I'm going to make one observation. Don't use the "--fixed" switch in the options. I left this out for a very good reason.....I'll explain why.

IF you're running a bog-standard Puppy/Dog/whatever exactly as it comes, OOTB, with default settings, "--fixed" works fine. Especially if you have good eyesight, and can clearly read the tiny size of the text as reproduced on these modern high-res monitors.

I, however, CAN'T.

After years of working in the minerals-processing sector, I have somewhat degraded eyesight. I was always short-sighted, even as a kid, and I now can't bear bright light either. I run dark themes, AND a larger global font-size across the kennels with non-standard, custom fonts; with the way the GUI shows in your "modded" version, for ME everything is 'squashed up', and half the buttons are either cut-off or missing.....entirely due to the "--fixed" geometry switch.

The removal of the "fixed" --switch cures all that.....and allows the GUI to expand/shrink to suit whatever system parameters an individual may have in place. Personally, I've never seen the point in making GUIs as tiny as possible; you want to be able to read them, and just as importantly, to interact with them.

Which just goes to show; when coding any app/utility, especially when giving it a GUI interface, you not only have to get your functional code working, you ALSO have to consider all the possible system variations the app might be used with.....and try to picture how your GUI will work for everyone, not just the way it appears on your own system. :)

It's a trap quite a few devs fall into.....you're not the first by ANY means, and I seriously doubt you'll be the last! :D It took me several attempts to understand why things never looked quite right when I first started playing around with YAD.....there ARE a lot of options, not all of which are always appropriate, AND they have to be used in just the right order. GNOME devs might come in for a lot of stick, but they do at least try to adhere to what's known as the HIG - "Human Interface Guidelines". Which try to ensure that things will always look the same, regardless of who uses them.

It's not criticism, mate, it's just the way things are..!

(Windows devs don't have this problem. 95% of users never modify their systems in any way at all, and everybody's singing from the same hymn-sheet, so to speak. There's only one permitted way of building GUIs, using Visual Studio, and that's Microsoft's way. Like it or loathe it, you don't get a say in the matter; if you want your app accepted, it must be built according to official guidelines.....)

Mike. ;)


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Tue Jan 18, 2022 1:29 pm
by gychang

seems like an elegant solution. WIll the following script achieve the same result, if I need to run sda2 and sda1(always mounted)?

mount /mnt/sda2 && fstrim -a

trying to learn...


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Tue Jan 18, 2022 1:52 pm
by mikewalsh
gychang wrote: Tue Jan 18, 2022 1:29 pm

seems like an elegant solution. WIll the following script achieve the same result, if I need to run sda2 and sda1(always mounted)?

mount /mnt/sda2 && fstrim -a

trying to learn...

Um; needs a couple of modifications, Greg. If, as you say, your sda1 and sda2 are always auto-mounted - or you manually mount them - then all you would need would be:-

Code: Select all

fstrim -a

IF you were to mount them yourself, via the command, you would need to use:-

Code: Select all

mount /dev/sda2 && fstrim -a

.....because until you mount it, it's just a device. It doesn't become /mnt/sda2 until it's been mounted into the file-system at that point. You also need to add the '-v' option, too, because without it fstrim simply runs the command without any output, confirmation OR otherwise.

Fstrim automatically searches for any drive that supports T.R.I.M. It will ONLY apply the command to a drive that does.....drives that don't will be silently ignored.

Mike. ;)


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Tue Jan 18, 2022 1:54 pm
by bigpup

Heh. Have you ANY idea - any at all - just how hard it is to track down an 'inspiring' icon for summat like an SSD?

Sure do.
Before I made that post about the icon.
I looked around to try and find one, to suggest.
That replacement, one you picked, is not bad!

Thank you for being willing to consider ideas and suggestions, by others! :thumbup:
As you can see by what mistfire posted.
People will help you, if you are willing to listen.

That info about:

Don't use the "--fixed" switch in the options.

I never really thought about that.
Thanks for that understandable info.

This is really turning into a must have utility. :thumbup:

It just gets better and better as improvements are added!!


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Tue Jan 18, 2022 2:23 pm
by mikewalsh

@bigpup :-

I tend to take the view - more & more these days - that once I publish anything, it then becomes "community property", as it were. And since we want things like this to be as simple & easy to use as possible, for all Puppians, I'd be daft NOT to take suggestions, improvements, etc, into account.

I'm the first to admit that my coding skills, vastly improved though they are compared to my early attempts several years ago, are NOT that great. I've no problem with incorporating improvements, certainly where I can understand them. The only thing that miffs me is when somebody takes something of mine, modifies it a bit, then tries to pass it off as their own. Now that's just plagiarism....and it HAS happened, on a couple of occasions! :evil:

Mike. :)


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Tue Jan 18, 2022 3:49 pm
by gychang
mikewalsh wrote: Tue Jan 18, 2022 1:52 pm
gychang wrote: Tue Jan 18, 2022 1:29 pm

seems like an elegant solution. WIll the following script achieve the same result, if I need to run sda2 and sda1(always mounted)?

mount /mnt/sda2 && fstrim -a

trying to learn...

Um; needs a couple of modifications, Greg. If, as you say, your sda1 and sda2 are always auto-mounted - or you manually mount them - then all you would need would be:-

Code: Select all

fstrim -a

IF you were to mount them yourself, via the command, you would need to use:-

Code: Select all

mount /dev/sda2 && fstrim -a

.....because until you mount it, it's just a device. It doesn't become /mnt/sda2 until it's been mounted into the file-system at that point. You also need to add the '-v' option, too, because without it fstrim simply runs the command without any output, confirmation OR otherwise.

Fstrim automatically searches for any drive that supports T.R.I.M. It will ONLY apply the command to a drive that does.....drives that don't will be silently ignored.

Mike. ;)

oops... very good info Mike!! :thumbup2:


Re: TRIM4SSD-portable v1.4 - Manual 'TRIM' utility for SSDs.....noarch package

Posted: Tue Jan 18, 2022 11:37 pm
by bigpup
mistfire wrote: Tue Jan 18, 2022 10:26 am

@mikewalsh

I made some modifications on your trim4ssd. It is now flexible and dynamic and the gui was improved
Check the package that I sent

Tried this version 1.4b on my computer, that does not list SSD drives as sdx whatever.
Now I can choose the SSD, showing in the drop down mount list.
nvme0n1 is my SSD.
.

Screenshot.png
Screenshot.png (173.95 KiB) Viewed 1220 times