<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 2, 2024 at 4:13 AM Stephen Worthington <<a href="mailto:stephen_agent@jsw.gen.nz">stephen_agent@jsw.gen.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 2 Jul 2024 13:14:40 +0800, you wrote:<br>
<br><br>
Better than using fstrim, you should now use the discard option in<br>
fstab. This is what I have on my main MythTV box:<br>
<br>
LABEL=ssd2 / ext4 discard,errors=remount-ro 0 1<br>
<br>
This causes trim to be done on a file at any time the filesystem<br>
deletes a file or reduces the size of a file. Or when the system<br>
stops using any areas of the partition for its control data.<br>
<br>
I still do have the fstrim job running, but these days it is normally<br>
a systemd unit. I have added an override to Ubuntu's standard once a<br>
week fstrim to run it once a day:<br>
<br>
root@mypvr:/etc# systemctl cat fstrim<br>
# /lib/systemd/system/fstrim.service<br>
[Unit]<br>
Description=Discard unused blocks on filesystems from /etc/fstab<br>
Documentation=man:fstrim(8)<br>
ConditionVirtualization=!container<br>
<br>
[Service]<br>
Type=oneshot<br>
ExecStart=/sbin/fstrim --listed-in /etc/fstab:/proc/self/mountinfo<br>
--verbose --quiet-unsupported<br>
PrivateDevices=no<br>
PrivateNetwork=yes<br>
PrivateUsers=no<br>
ProtectKernelTunables=yes<br>
ProtectKernelModules=yes<br>
ProtectControlGroups=yes<br>
MemoryDenyWriteExecute=yes<br>
SystemCallFilter=@default @file-system @basic-io @system-service<br>
root@mypvr:/etc# systemctl cat fstrim.timer<br>
# /lib/systemd/system/fstrim.timer<br>
[Unit]<br>
Description=Discard unused blocks once a week<br>
Documentation=man:fstrim<br>
ConditionVirtualization=!container<br>
ConditionPathExists=!/etc/initrd-release<br>
<br>
[Timer]<br>
OnCalendar=weekly<br>
AccuracySec=1h<br>
Persistent=true<br>
RandomizedDelaySec=6000<br>
<br>
[Install]<br>
WantedBy=timers.target<br>
<br>
# /etc/systemd/system/fstrim.timer.d/override.conf<br>
[Unit]<br>
Description=Discard unused blocks once a day<br>
<br>
[Timer]<br>
OnCalendar=<br>
OnCalendar=daily<br>
AccuracySec=10m<br>
<br>
The specs for the Samsung SSD 860 QVO drive say it has a warranty for<br>
up to 1440 TBW (terabytes written). What does the smartctl report say<br>
has been written to it so far? You should see it reported in the<br>
output of "smartctl -a /dev/sda". Look for something like "Data Units<br>
Written".<br><br></blockquote><div>The mount status shows that the discard option is included by default on my btrfs drives for the nvme.<br><span style="font-family:monospace">/dev/nvme0n1p2 on / type btrfs (rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=506,subvol=/@)</span></div><div> </div><div>However it's not mentioned in the SATA ext4 partitions.</div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">/dev/</span><span style="font-weight:bold;color:rgb(255,84,84);background-color:rgb(255,255,255)">sda</span><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">2 on /video-music type ext4 (rw,relatime)</span><br>
<br></span></div><div><span style="font-family:arial,sans-serif">I'll add that to the fstab and also the ssd option.</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">Thanks to all for the advice.</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">JIm A</span><span style="font-family:monospace"><br><br></span></div></div></div>