I am looking at the SD I/O bandwidth. It shows that there is a constant write process, at around 45-55 kB/sec. Probably this is part of the normal process of writhing the position of the planes in the web page location, but I am worried about wear of the SD card.
I did the following to alleviate this issue, at least in my mind.
First I edited /etc/fstab (sudo nano /etc/fstab) to add this line: none /var/log tmpfs size=1M,noatime 0 0
Secondly I have tuned the write caching of the linux kernel by editeding /etc/sysctl.d/local.conf (sudo nano /etc/sysctl.d/local.conf). It was nothing there, so I added:
To see all the settings use: sysctl -a vm.dirty_background_ratio â This is the percentage of RAM that can be filled with dirty memory pages before it is written to disk. The default value on Raspbian is 10. vm.dirty_ratio â This is the maximum amount of RAM that can be filled with dirty pages before writing the dirty memory pages to disk. The default value on Raspbian is 20.
Any comments/ideas?
Can we make the web page file to be part of a RAM tmpfs drive (symlinked)? I am thinking about the whole folders /var/www/html/graphs/, /var/log/ and, if present, /var/www/html/dump978/data/
LE: After the above changes the âDisk I/O bandwidthâ changed to 29.4kB/sec.
And the pic. Initial values, then a while with the 1min delay, and now with 2 minutes delay.
The Writes decreased from average of 45kB/s to 15kB/s and iops from an average of 6 iops to 1.5 iops.
I solved microSD card failure due to writes in an entirely different way
Saved backup copies of microSD cards on my Desktop.
Waited till there was a special offer / sale at local computer & electronics store, selling Adata 8 Gb class10 microSD card for Candain $5.99 (US $4.59, ÂŁ3.54, âŹ3.95).
I purchased a bunch of these.
OK, I have burned one of backup images to a microSD card. It is done just like Raspbian or Piaware image is burned to microSD card.
While making backup copy, you can choose a name of backup copy with or without .img extension. However a name with .img extension will make finding & selecting the backup easier during burning of backup to microSD card,
Bear in mind you can boot and run a RPi3 up from an external USB HDD and forgo an SD card entirely. You can pick up 80GB drives from around $20 new. Not sure if earlier Piâs can do this.
I have external HDDâs but it would be a cumbersome installation. When in reality, it just needs that the writes to be done on the tmpfs partition (RAM) instead of the SD.
Caching the writes with deferring helps.
Also, well known SD manufacturers add wear leveling algorithms to their cards, but donât expect the cheap, no-name ones to have that implemented.