1 |
On Sun, Apr 26, 2020 at 12:15 PM <tuxic@××××××.de> wrote: |
2 |
> |
3 |
> On 04/26 11:20, Rich Freeman wrote: |
4 |
> > On Sun, Apr 26, 2020 at 10:52 AM <tuxic@××××××.de> wrote: |
5 |
> > > |
6 |
> > > Fstrim reports about 200 GiB of trimmed data. |
7 |
> > > |
8 |
> > |
9 |
> > My suggestion would be to run fstrim twice in a row and see how fast |
10 |
> > it operates and what the results are. If the second one completes |
11 |
> > very quickly that suggests that the drive is sane. I'd probably just |
12 |
> > run it daily in that case, but weekly is probably fine especially if |
13 |
> > the drive isn't very full. |
14 |
> > |
15 |
> |
16 |
> host:/root>fstrim -v / |
17 |
> /: 3.3 GiB (3578650624 bytes) trimmed |
18 |
> host:/root>fstrim -v / |
19 |
> /: 0 B (0 bytes) trimmed |
20 |
> |
21 |
> This time the first fstrim reports a small mount of trimmed |
22 |
> data and second one no fstrimmed data at all. |
23 |
> |
24 |
|
25 |
Ok, I became a bit less lazy and started looking at the source. |
26 |
|
27 |
All fstrim does is send an FITRIM ioctl to the kernel for the device. |
28 |
This is implemented in a filesystem-dependent manner, and I couldn't |
29 |
actually find any documentation on it (actual documentation on the |
30 |
ioctl - not the fstrim manpage/etc). A quick glimpse at the ext4 |
31 |
source suggests that ext4 has a flag that can track whether a group of |
32 |
blocks has been trimmed yet or not since it was last deallocated. So |
33 |
ext4 will make repeated fstrim runs a no-op and the drive won't see |
34 |
these. |
35 |
|
36 |
At least, that was what I got after about 5-10min of browsing. I |
37 |
didn't take the time to grok how ext4 tracks free space and so on. |
38 |
|
39 |
Incidentally, in the other thread the reason that dry-run didn't |
40 |
report anything to be trimmed is that this is hard-coded: |
41 |
printf(_("%s: 0 B (dry run) trimmed on %s\n"), path, devname); |
42 |
https://github.com/karelzak/util-linux/blob/master/sys-utils/fstrim.c#L109 |
43 |
|
44 |
Otherwise the ioctl returns how much space was trimmed, and fstrim outputs this. |
45 |
|
46 |
-- |
47 |
Rich |