Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] "Amount" of fstrim? (curiosity driven, no paranoia :)
Date: Sun, 26 Apr 2020 15:20:47
Message-Id: CAGfcS_=t5uABf69+PfZ4qtyMSvPYWqatWRb5ghZdB7PKJ6M1KQ@mail.gmail.com
In Reply to: [gentoo-user] "Amount" of fstrim? (curiosity driven, no paranoia :) by tuxic@posteo.de
1 On Sun, Apr 26, 2020 at 10:52 AM <tuxic@××××××.de> wrote:
2 >
3 > Fstrim reports about 200 GiB of trimmed data.
4 >
5 > From the gut this looks quite a lot -- the whole
6 > partition is 256 GB in size.
7 >
8 > Smartclt report for the drive:
9 > Data Units Written: 700,841 [358 GB]
10 >
11 > Each week 200 GiB fstrimmed data for a partition of
12 > 256 GB in size and since the beginning I have written
13 > only 358 GB to it.
14 >
15 > How does this all fit together?
16
17 It doesn't fit together, because the amount of space trimmed has
18 nothing to do with the amount of data written.
19
20 How much free space is there? I would think that fstrim would just
21 trim all unused blocks on the filesystem. Unless it maintained state
22 it would have no idea what has changed since the last time it was run,
23 so if you ran it 10 times in a row it would trim 200GiB each time.
24
25 Unless your NVMe is brain-dead the only real downside to running it
26 more often is the IO. If you trim 200GiB of data 100x in a row the
27 99x after the first one should all be no-ops if the drive is
28 well-designed. An fstrim should just be a metadata operation.
29
30 Now, not all flash storage is equally well-implemented, and I suspect
31 the guidelines to avoid running it often or using discard settings are
32 from those who either have really cheap drives, or ones from a long
33 time ago. A lot of linux advice tends to be based on what people did
34 10+years ago, and a lot of linux design decisions get made to
35 accommodate the guy who wants everything to work fine on his 386+ISA
36 and SGI Indigo in his basement.
37
38 My suggestion would be to run fstrim twice in a row and see how fast
39 it operates and what the results are. If the second one completes
40 very quickly that suggests that the drive is sane. I'd probably just
41 run it daily in that case, but weekly is probably fine especially if
42 the drive isn't very full.
43
44 --
45 Rich

Replies