Solved [SOLVED] Manually Trimming an SSD Question

Good Morning All,

Before I ported over to FreeBSD (which I am quite happy with), I had a command in Linux that would allow me to manually issue a fstrim command on a mounted file system.
Ref: http://www.unix.com/man-page/All/8/fstrim/

This utility did two things: It showed the user on the cli the amount of data that needed to be trimmed, and then actually trimmed the file system at the same time. I wish to validate on my system that the UFS2 FS is actually following the trim that was setup in newfs -U -t <Device/slice>

While tunefs in single user mode tells me that the trim flag is indeed set.....I'd really like to see what the filesystem is actually doing.

I have read through wiki.freebsd, this webstite, wblocks excellent article on SSD's, the man pages, searched through the ports tree for anything that has "trim" in the file name, and lastly performed a pkg search trim. I have also done searched via google and yahoo and found a site that roughly approximates cli command parallels between Linux and FreebSD. Nothing is coming up.

I don't see any similar command in FreeBSD that roughly parallels fstrim in linux. So I am assuming it is a script, or there is some procedure to do this in FreeBSD. If it's a procedure, then I'll encapsulate it in a shell script if a script doesn't already exist to do this somewhere.


Can someone please enlighten me how to accomplish this under FreeBSD?


Thank you,


Sincerely and respectfully,

Dave
 
Re: Manually Trimming an SSD Question

The fstrim man page shows it's just a brute-force application: tell the drive that every block not used by the filesystem is not in use. I don't see how this would tell whether UFS is doing a trim or not.

The only reason to use this is if you don't trust UFS to do the trim. Of course, you have to trust fstrim to only trim blocks that actually are unused. Otherwise, it risks losing data.
 
Re: Manually Trimming an SSD Question

Thank you for the reply,

Let me explain where this question comes from:

My SSD based FS's under Linux (ext4) were mounted with the discard option in them, which was supposed to trigger the device's trim feature. And I would periodically check the mount command to validate that the discard flag was set. Yet I experienced inconsistency in it's implementation. Sometimes it worked, other times it did not. No pattern to it that I could determine.

I then reacted to this anomaly by periodically issuing a fstrim -v /. Sometimes there would be nothing to trim, other times, there would be ~ 500mb that fstrim took care of that the file system didn't do on it's own.

As a result, I became distrustful of EXT4's trim feature and started using fstrim periodically to keep the SSD maintained properly.

So let me ask: Am I to understand that the UFS2 trim feature has been tested sufficiently enough that I need not verify/validate that the trim function is doing it's job?
I ask this as no flames/bait are intended at all...and of course can be written off to my continuing acclimation to a FreeBSD environment, coming from not the best experience under Arch Linux.

In saying that, when I built a new fs for my root partition under FreeBSD, I did this: newfs -U -t <gpt partition name>, where the "-t" being the parameter needed to instantiate native UFS2 trimming. And in single user mode, the tunefs -t enable returns to me that the flag is already set to enable.


Please Advise,

Sincerely and respectfully,

Dave
 
Re: Manually Trimming an SSD Question

dcbdbis said:
So let me ask: Am I to understand that the UFS2 trim feature has been tested sufficiently enough that I need not verify/validate that the trim function is doing it's job?

I can't prove that. But how can fstrim be proven to help, either? To really know would require a utility that would query the drive and compare the internal block status. It never occurred to me to look for something like that.
 
Re: Manually Trimming an SSD Question

Hello wblock,

I totally get your point of:
wblock@ said:
I can't prove that. But how can fstrim be proven to help, either?

If ext4's discard feature was flaking out, how can I be sure that fstrim wasn't being flakey either?

Thank You for the reply,


I'll mark the post as solved.


Sincerely and respectfully,

Dave
 
Back
Top