Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fstrim(8) Recommendation

3 views
Skip to first unread message

John Conover

unread,
Jan 12, 2023, 9:50:04 PM1/12/23
to

I'm installing an SSD replacement for an HD in a small 24/7 mail
server.

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.

Thanks,

John

--

John Conover, con...@panix.com, http://www.johncon.com/

Jeffrey Walton

unread,
Jan 12, 2023, 10:00:05 PM1/12/23
to
On Thu, Jan 12, 2023 at 9:45 PM John Conover <con...@panix.com> wrote:
>
> I'm installing an SSD replacement for an HD in a small 24/7 mail
> server.
>
> 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 don't use fstrim, so I can't offer any insight.

But for reliability of your mail server:

- RAID 1 - mirroring - for reliability.

- Lots of RAM to avoid using the swap file.

- Use a small HDD for your swap file. That will reduce wear on your
SSD. Set swappiness to a low value, like 2 or 3, to keep stuff in RAM
and out of swap.

Jeff

Matthias Böttcher

unread,
Jan 13, 2023, 3:40:05 AM1/13/23
to
Am Fr., 13. Jan. 2023 um 03:45 Uhr schrieb John Conover <con...@panix.com>:
>
> I'm installing an SSD replacement for an HD in a small 24/7 mail
> server.
>
> 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.
>
> Thanks,
>
> John

Hi John,

take a look at the systemd units
fstrim.timer
fstrim.service
e2scrub_all.service
e2scrub_all.timer
e2scrub_reap.service

Trimming swap partitions is not provided.

HTH

Matthias

Stefan Monnier

unread,
Jan 13, 2023, 9:50:05 AM1/13/23
to
> 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.


Stefan

hede

unread,
Jan 14, 2023, 6:40:05 AM1/14/23
to
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

Andy Smith

unread,
Jan 15, 2023, 11:20:06 AM1/15/23
to
Hello,

On Thu, Jan 12, 2023 at 06:44:59PM -0800, John Conover wrote:
> I'm installing an SSD replacement for an HD in a small 24/7 mail
> server.
>
> I would appreciate suggestions for the most reliable way to do
> fstrim(8).

The two ways to do it are:

a) Add "discard" into the mount options for each filesystem (not
supported for swap)

b) Let the systemd service fstrim do it periodically

These days there shouldn't really be any reliability issues
whichever way you do it. Mostly people prefer (b) since it happens
in batches rather than a tiny discard every time something is
deleted.

So I would just do nothing out of the ordinary and let the default
fstrim service do its job.

Things get more complicated if you are running virtual machines, or
LVM volumes or things like that, but it sounds like you aren't.

Cheers,
Andy

--
https://bitfolk.com/ -- No-nonsense VPS hosting
0 new messages