[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: fstrim(8) Recommendation



On Fri, 13 Jan 2023 09:49:17 -0500 Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> > I would appreciate suggestions for the most reliable way to do
> > fstrim(8). Reliability is more important than speed, and the machine
> > will require a swap partition.  
> 
> I think the answer depends on why you (think you) need fstrim.
> AFAIK in most cases the answer is: just don't bother.

I don't think so. Wear leveling works better the more free space is present. 

With typical filesystems every block ever written remains written, even if it was unlinked later on. fstrim helps the SSD to know which blocks are really free for internal usage by the SSD and as such supports a good wear leveling. 

There are multiple ways to trim. Either via the filesystem itself, like a "discard" mount option, which means the filesystem instantly trims unlinked blocks. Or via some batched discard like fstrim. 

Both do have pros and cons while I think for fstrim the pros do prevail. 

Like for example some filesystem discard option AFAIK means to trim the disc for every single unlink operation. This is sub-optimal. Using a batched discard is more efficient as it results in bigger blocks of discarded regions which is better for the erase block mapping of flash media - AFAIK. 

hede


Reply to: