Tinker Board Forum

Full Version: Slow SD card fixed with TRIM
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a Tinkerboard that i specifically bought to run an influxdb server, and it needed around 1GB RAM just for the service. After a year the system grinded to a halt, and I started fiddling with writeback, kernel parameters.. reinstalling.. 

In the end I bought a new SD card and reinstalled, now working fine. But I got interested in why it is so slow, while showing no data corruption. So I tried a few things:
  • Zeroing the SD card with dd if=/dev/zero of=/dev/sda: No differnce
  • Formatting with Windows SD card formatter: No difference (possible because of USB reader, see below)
Then i ran "fstrim -av" on another SBC and it reported 11GB trimmed  (!) it should be way less I thought, shouldnt trim be running periodically? Then I noticed that the fstrim.timer service was not enabled even though installed. I tried to run fstrim on my slow SD card but operation was not supported when running over USB SD card reader. So to test I ended up writing a new OS image to the card (slow... 1.5 MB/sec). Booting it up in the Tinkerboard MMC slot, dd:ing a file, still slow.

Then I ran "fstrim -a" and after that I had 18MB/sec write speeds.

The fstrim.timer service is not standard on all my debian installations, so what I did was to add fstrim -a to cron.daily on all my SBCs. So what I learned here is:
  • Nothing execpt TRIM command works to "reset" SD card.
  • Most USB card readers dont support TRIM command
  • fstrim is for some strange reason not enabled on any of my SBCs as default
  • Changed my write rates around 1MB/sec to 13MB/sec on most of my SBCs now around 18MB/sec (on par with SD card spec)
  • Influxdb just destroys SD cards... it writes and deletes heavily when sharding(?) data.
  • Docker in itself is also heavy on writes and deletes, if you are developing and trying different images.
My suspicion is that fstrim is mostly thought to work with SSDs, and nobody figured its heavlily beneficial to SD cards too. I can for my life not understand why periodic trimming is not enabled by default on operating systems that are made to run off SD cards. And its been the same on TinkerOS, Raspbian and Armbian.