Page 1 of 1

Some questions about SSDs & fstrim

Posted: Mon Apr 04, 2022 10:41 am
by courtage

I'm running Bionic64 as a frugal install with a savedir, all from a 1TB Samsung 870 SSD as sda1

The days are long passed that I can remember the ins and outs of the layered fs in Puppy, so I'm slightly confused as to how fstrim will & won't work on my SSD.

~ If I issue "fstrim -v /mnt/sda1" I get "fstrim: /mnt/sda1: the discard operation is not supported"

This is presumably because /dev/sda1 is actually mounted on /initrd/mnt/dev_save and not on /mnt/sda1

~ If I issue "fstrim -v /mnt/home/" , it trims the SSD

~ If I make a directory anywhere as a mountpoint and mount /dev/sda1on it, and then issue the fstrim with that mountpoint as the target, it trims the SSD.

I know theres a pet gui but I don't really need that, I'm just going to set up a cron job.

so is there any reason not to simply run

[/code]
fstrim /initrd/mnt/dev_save
[/code]

?


Re: Some questions about SSDs & fstrim

Posted: Mon Apr 04, 2022 11:58 am
by bigpup

Not sure about the answer to your question.

However, if the save is on sda1.
sda1 is kind of in a soft mount condition, because the save is mounted and it's file system is layered into the operating file system.
So to do trim on sda1.
First do a full mount by clicking on the desktop drive icon for sda1.
then do trim command on /mnt/sda1

Note:
/mnt/home/ is usually to Puppy the location the save is.

So, maybe fstrim /initrd/mnt/dev_save would also work.
Only way to know is try it.

I do wonder if it actually will trim the complete sda1 or just the file system in the save on sda1 :idea:
The save is a Linux file system inside a file or directory(folder).

fstrim is used on a mounted filesystem to discard (or "trim")
blocks which are not in use by the filesystem.

10 ways to do anything, but which one is it the best way to do it. :lol:


Re: Some questions about SSDs & fstrim

Posted: Mon Apr 04, 2022 12:34 pm
by backi

Hi @courtage

Maybe try with:
fstrim -av

Partitions must be mounted.

Maybe useful...more here:

Trimming SSD Manually.(https://easylinu ... /ssd.html)


Re: Some questions about SSDs & fstrim

Posted: Mon Apr 04, 2022 12:39 pm
by courtage

yes I know all that, I'm specifically asking about the slight peculiarities that Puppy presents.


Re: Some questions about SSDs & fstrim

Posted: Mon Apr 04, 2022 1:18 pm
by dimkr

woof-CE now has https://github.com/puppylinux-woof-CE/w ... nit.d/trim, which runs fstrim once a week.


Re: Some questions about SSDs & fstrim

Posted: Tue Apr 05, 2022 4:40 am
by Phoenix

@courtage :
The probable reason as to why it won't fstrim /mnt/sda1 is that you didn't mount it there, and therefore that directory is part of your savefile/folder. Directories do take up data in order to exist. It will not allow trimming or allow that to occur, because the device used to mount the savefile is special. It is a loop device, although the full name is a loopback device. What this enables you to do is to mount a file as if it were an ordinary disk. Actual disk images (like dd'ing an actual drive) take a bit more work to mount. But you cannot issue trims because of this reason.

Reasons as to why you should not run fstrim on /mnt/home:

  1. It's a USB and you'll kill it faster than a standard SSD. (Less cycles!)
  2. It probably won't do any favors for a USB, even with sequential reading. Well, maybe a little bit, but I think burning cycles away just for that little boost isn't worth it.

Reasons why to do so:

  1. SSDs suffer from what is called write amplification, although with some better written code this can be minimized a lot, such as with ext4. To check the fragmentation level of your ext4 partition, run fsck -nvf /dev/device.
  2. Informs SSDs of which cells are free, therefore wear leveling is more accurate. It also improves performance.
  3. Fragmentation tolerance limit: Does not apply to Linux filesystems, but it does to Windows NTFS! (Explains the schedule if you ever checked that)
  4. Lastly it is very very good at ensuring data is deleted, forever. Once you did it almost no one will be able to get it back. Now if you care about your data, you probably will not want TRIM at all. Otherwise tools such as ext4magic won't be able to get it back for you! (Although mkfs does implicitly enable TRIM so now you'll have to manually say, no you don't want it.)

Notes: There are a couple of trips regarding ultimate destruction of data. TRIM only will do it if its configured right and implemented properly. So smashing it to atoms may be a better bet.

Things not to do:
Spamming fstrim, it serves no point and will waste cycles. And it kills poor quality SSDs faster.


Re: Some questions about SSDs & fstrim

Posted: Mon Apr 25, 2022 11:11 pm
by gychang
dimkr wrote: Mon Apr 04, 2022 1:18 pm

woof-CE now has https://github.com/puppylinux-woof-CE/w ... nit.d/trim, which runs fstrim once a week.

I am running FP64, does it already have "built-in" fstrim for my SSD as long as it is mounted?


Re: Some questions about SSDs & fstrim

Posted: Tue Apr 26, 2022 6:02 am
by bigpup

What is FP64?


Re: Some questions about SSDs & fstrim

Posted: Tue Apr 26, 2022 12:45 pm
by gychang
bigpup wrote: Tue Apr 26, 2022 6:02 am

What is FP64?

fossapup64.


Re: Some questions about SSDs & fstrim

Posted: Tue Apr 26, 2022 7:28 pm
by bigpup

In a terminal (console) use command:

Code: Select all

fstrim -help

If you get the help info, it has fstrim.

I use this in Fossapup64 9.5
viewtopic.php?t=4907

That Woof-CE change is not in Fossapup64.
So you will have to use the command fstrim or the trim program I gave a link for.