[SOLVED] fstrim.service failure

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
LanceM

Re: fstrim.service failure

Post by LanceM »

Did you enable optimization on Windows?
How did you disable it? I can run the TRIM test with it disabled and sharing an EFI. I will do a dual boot install offline and test TRIM.
ajgringo619

Re: fstrim.service failure

Post by ajgringo619 »

LanceM wrote: Wed Sep 02, 2020 4:37 pm Did you enable optimization on Windows?
How did you disable it? I can run the TRIM test with it disabled and sharing an EFI. I will do a dual boot install offline and test TRIM.
I disabled Windows optimization a few days ago after finding out about the bug where it can't remember when it last ran. I ran it once manually, but won't re-enable it until the bug is fixed.
LanceM

Re: fstrim.service failure

Post by LanceM »

I disabled Windows optimization
I'm trying to duplicate your setup.
How did you disable Windows Optimization.
I can disable TRIM but apparently only for NTFS.
ajgringo619

Re: fstrim.service failure

Post by ajgringo619 »

I believe it was in Programs --> Administrative Tools --> Disk Cleanup.
LanceM

Re: fstrim.service failure

Post by LanceM »

I disabled Optimization by going to Optimization and shut the schedule off.
So this is what happened:
I did an install as close to yours as possible. Win10 separate SSD, then installed Mint 20 Cinnamon with all partitions similar to yours on another SSD.
The end result is that it made no difference. Manual TRIM and Scheduled TRIM all "Finished" without errors. I'll post the scheduled TRIM only for you to see. I don't know why yours is broken.
Dual boot with Windows Optimization Scheduled disabled

Code: Select all

Sep 08 16:27:51 Dual systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
Sep 08 16:28:21 Dual fstrim[845]: /mnt/MY-DATA: 13.7 GiB (14676901888 bytes) trimmed on /dev/sdb5
Sep 08 16:28:21 Dual fstrim[845]: /boot/efi: 63.3 MiB (66350080 bytes) trimmed on /dev/sda1
Sep 08 16:28:21 Dual fstrim[845]: /boot: 808.8 MiB (848023552 bytes) trimmed on /dev/sdb1
Sep 08 16:28:21 Dual fstrim[845]: /: 19.5 GiB (20913569792 bytes) trimmed on /dev/sdb3
Sep 08 16:28:21 Dual systemd[1]: fstrim.service: Succeeded.
Sep 08 16:28:21 Dual systemd[1]: Finished Discard unused blocks on filesystems from /etc/fstab.
ajgringo619

Re: fstrim.service failure

Post by ajgringo619 »

I really appreciate the time/effort you've put into this; just wish we could get past it. If it ends up being hardware-related, then there's no way you can do anything more.
LanceM

Re: fstrim.service failure

Post by LanceM »

I don't mind. I use ICY-Dock and have a lot of old beater SSD. Afterwards, I just erase them. I use Foxclone or Clonezilla to clone them from images I've made. Here's something you can try:

Code: Select all

sudo btrfs scrub start / 
Wait for drive to quit blinking, then:

Code: Select all

sudo btrfs scrub status /
See if any errors are reported and fixed.
Last edited by LanceM on Wed Sep 02, 2020 7:07 pm, edited 1 time in total.
ajgringo619

Re: fstrim.service failure

Post by ajgringo619 »

(Minor typo in your 2nd command)

Code: Select all

$ sudo btrfs scrub status /
scrub status for ab3b3cfb-7957-4191-b65c-2074deafaa49
	scrub started at Wed Sep  2 16:02:55 2020 and finished after 00:00:15
	total bytes scrubbed: 7.83GiB with 0 errors
LanceM

Re: fstrim.service failure

Post by LanceM »

Thanks. I fixed the typo.
Last edited by LanceM on Thu Sep 03, 2020 10:34 pm, edited 1 time in total.
LanceM

Re: fstrim.service failure

Post by LanceM »

Automatic TRIM is not enabled by default on LMDE 4. I have it enabled. I checked the log on my laptop and the output is much like your Aug 24 and does not say "Finished"
It has not been started in a coouple weeks, so this is the scheduled TRIM output

Code: Select all

Logs begin at Thu 2020-09-03 08:49:27 MDT, end at Thu 2020-09-03 09:48:18 MDT. --
Sep 03 08:49:30 de4 systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
Sep 03 08:49:40 de4 fstrim[575]: /home: 17.3 GiB (18564419584 bytes) trimmed on /dev/mmcblk0p3
Sep 03 08:49:40 de4 fstrim[575]: /: 33.1 GiB (35574759424 bytes) trimmed on /dev/mmcblk0p2
Sep 03 08:49:40 de4 fstrim[575]: /boot/efi: 505.9 MiB (530448384 bytes) trimmed on /dev/mmcblk0p1
Sep 03 08:49:40 de4 systemd[1]: fstrim.service: Succeeded.
Sep 03 08:49:40 de4 systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab.
I can try and duplicate this:
One thing that may or not matter is my custom backup program. Daily, sometime between 8AM and 8PM, the backup runs. One of the first things it does is sync a few data directories from my Windows install and my /home directory (using unison). The Windows C-drive is mounted, synced, then unmounted.
if you tell me how.
ajgringo619

Re: fstrim.service failure

Post by ajgringo619 »

One other thing I noticed, besides the journal output, is I have noatime on all my SSD partitions. Again, just throwing out something new. As far as the script goes, the section that syncs my Windows stuff is pretty simple (this is being done as root). If you want the exact Python function, let me know:
1) Mount the Windows partition: mount UUID=A4DC8D83DC8D508A -o uid=1000,gid=1000,umask=022,dmask=022 /media/Windows-C
2) Next, run unison: su - my_username -c "unison"
3) Unmount the Windows partition: sync; umount UUID=A4DC8D83DC8D508A

My unison prefs file looks like this:

Code: Select all

root = /home/my_username
root = /media/Windows-C/Users/ajgri

path = Downloads
path = Development
path = Music
path = Pictures
path = Saved Games

ignore = Name desktop.ini
ignore = Path */Linux
ignore = Path */projects/Linux
ignore = Path */venv

perms = 0
batch = true
LanceM

Re: fstrim.service failure

Post by LanceM »

I see if I can figure the sync out. As far as I know noatime is obsolete. I used to use it, but not anymore. After this post:
viewtopic.php?p=1492407#p1492407
LanceM

Re: fstrim.service failure

Post by LanceM »

Too much trouble to figure the sync out. I guess you could disable it and see what happens next Monday.
ajgringo619

Re: fstrim.service failure

Post by ajgringo619 »

LanceM wrote: Thu Sep 03, 2020 12:57 pm I see if I can figure the sync out. As far as I know noatime is obsolete. I used to use it, but not anymore. After this post:
viewtopic.php?p=1492407#p1492407
The only reason I added the sync command was to make sure that all of the data was written to the Windows partition before I unmounted it. I only added noatime due to Pjotr's "Easy Linux Tips Project" recommendation.
LanceM

Re: fstrim.service failure

Post by LanceM »

I think you can remove it. If you do, remember to, afterwards, do

Code: Select all

sudo update-grub
LanceM

Re: fstrim.service failure

Post by LanceM »

On my test system I added noatime to etc/fstab, updated grub, rebooted and ran

Code: Select all

sudo systemctl start fstrim
TRIM still "Finished"
The etc/fstab edit looked like this

Code: Select all

btrfs   defaults,subvol=@,noatime 0
ajgringo619

Re: fstrim.service failure

Post by ajgringo619 »

The only difference on my fstab is I have noatime before defaults. It must be a one-off bug; I'm getting nowhere on the 'net and my StackExchange question hasn't even gotten a comment yet. Maybe this will all go away once I make the switch to LM20.
LanceM

Re: fstrim.service failure

Post by LanceM »

That noatime configuration came from Tony George. I sent him an email about it, and how to configure it for Btrfs. Back when I was testing writes to SSDs for noatime. It made no difference to writes. It doesn't on Ext4 either, at least not on systems I tested. It's obsolete for that, I think due to relatime.
ajgringo619

Re: fstrim.service failure

Post by ajgringo619 »

I decided to revisit this thread, and I'm finally getting the desired output from the fstrim.service:

Code: Select all

$ journalctl -u fstrim.service
-- Logs begin at Fri 2020-10-30 10:18:45 PDT, end at Tue 2020-11-10 15:17:13 PST. --
Nov 02 00:00:06 dss-mint systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
Nov 02 00:01:06 dss-mint fstrim[16832]: /media/Backup-Data: 729.5 GiB (783283601408 bytes) trimmed on /dev/sdb5
Nov 02 00:01:06 dss-mint fstrim[16832]: /boot/efi: 63.2 MiB (66308096 bytes) trimmed on /dev/sda1
Nov 02 00:01:06 dss-mint fstrim[16832]: /boot: 739.4 MiB (775307264 bytes) trimmed on /dev/sdb1
Nov 02 00:01:06 dss-mint fstrim[16832]: /: 62.5 GiB (67139670016 bytes) trimmed on /dev/sdb3
Nov 02 00:01:06 dss-mint systemd[1]: fstrim.service: Succeeded.
Nov 02 00:01:06 dss-mint systemd[1]: Finished Discard unused blocks on filesystems from /etc/fstab.
-- Reboot --
Nov 09 00:00:30 dss-mint systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
Nov 09 00:01:41 dss-mint fstrim[31881]: /media/Backup-Data: 694.4 GiB (745545981952 bytes) trimmed on /dev/sdb5
Nov 09 00:01:41 dss-mint fstrim[31881]: /boot/efi: 63.2 MiB (66308096 bytes) trimmed on /dev/sda1
Nov 09 00:01:41 dss-mint fstrim[31881]: /boot: 738.4 MiB (774217728 bytes) trimmed on /dev/sdb1
Nov 09 00:01:41 dss-mint fstrim[31881]: /: 50.7 GiB (54389039104 bytes) trimmed on /dev/sdb3
Nov 09 00:01:41 dss-mint systemd[1]: fstrim.service: Succeeded.
Nov 09 00:01:41 dss-mint systemd[1]: Finished Discard unused blocks on filesystems from /etc/fstab.
I recently reinstalled my dual-boot and went with Mint 20, which I'm almost certain is why this is working now.
LanceM

Re: [SOLVED] fstrim.service failure

Post by LanceM »

So why is it working now?
Locked

Return to “Hardware Support”