guix-devel
[Top][All Lists]
Advanced

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

Re: fstrim and SSDs and cron; was: Re: cron-service


From: Danny Milosavljevic
Subject: Re: fstrim and SSDs and cron; was: Re: cron-service
Date: Wed, 18 May 2016 07:09:04 +0200

Hi,

> FWIW, I use SSDs in all my computers and have never run fstrim.  Feels
> a lot like the "defragment your hard drive" days.

If you would run it now then it would free many gigabytes.

What it does and why it's needed:

Traditionally filesystems on hard disks would just reuse sectors once they are 
not needed by the filesystem anymore. For example to delete a file it would 
just remove the filename and update the usage bitmap metadata. That's it. It 
wouldn't do anything to the payload sectors. Later on, the payload sector could 
maybe be used for another file's payload.

For SSDs this is bad since they are trying to do wear levelling. SSDs work by 
providing an "hard-drive-like" interface to (many) flash blocks in hardware. A 
flash block can be written (actually: erased) only a limited number of times (< 
5000). So there's an algorithm in the drive fireware which makes sure to evenly 
use all the flash blocks. If you keep writing the same sector, it will 
eventually move and remap it to another formerly-empty flash block.

The problem with that is the "empty" in the last sentence. Which one is empty? 
As I said, the traditional filesystem wouldn't do anything to mark the payload 
setors as empty on the drive itself.

Therefore, a command called "TRIM" was added to the SATA protocol (and other 
things). fstrim will send the command to the drive, informing it about sectors 
that are actually unused now. In this way the SSD has more possible targets to 
move stuff to.

if you don't do it at all, the SSD will eventually run out of spare blocks and 
won't move stuff away anymore - which means one of the blocks is going to fail 
very soon (the ones that are written often - which are probably filesystem 
metadata blocks - maybe the usage bitmap). 

Of course it can still shuffle around used blocks - and probably does. 
Otherwise it would turn out to be very bad.

There's also the "discard" mount option which automatically trims - but 
documentation says that it's caused longevity problems in the past for some 
drives (probably because it sends the TRIM command too often).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]