Solved Preserving an SD card from writes.

I need to preserve the life of an SD Card I am currently running my APU2 fileserver from.
Usually I would have a NanoBSD build for this but I am currently collapsing functions in a single box.
Will build a NanoBSD for it later.
Now I need to preserve life.
So what recommendations do you have for me.
My first instinct is to use a memorydisk in fstab for /var just like NanoBSD.
/var does not need to be permanent correct? I will simply lose all contents on reboot.
I know logs ect...

What about /etc directory. Does it get written to much? NanoBSD uses MD here too.

How would I find what files are being written to? vmstat -o?
 
turn off atime on sd card volumes
use tmpfs on /tmp and /var/tmp
most of the writes are in /var/log /var/db /var/backups on such a system
buy 'high endurance' sd cards (they use 3d nand)
use find / -mtime -15 -type f to see what gets modified in the last days (15 here)
use iostat -I -x to see how much data was written till boot (kw/i)
 
high endurance sd cards cost like 2-2.5X more than a generic one
here they are about $11-12 for 32GB samsung/sandisk/kingston/adata
 
I mfs'ed /var/backup/ and now thinking about this one.
I really don't want to lose my pkg datbase.

No ill effects so far.
Would using tmpfs instead of /tmp and /var/tmp on MD bring any advantage?

Code:
# mount
/dev/mmcsd0p2 on / (ufs, local, noatime, soft-updates, journaled soft-updates)
devfs on /dev (devfs)
/dev/mirror/gm0p1 on /files (ufs, NFS exported, local, soft-updates)
/dev/md0 on /tmp (ufs, local, noatime, soft-updates)
/dev/md1 on /var/run (ufs, local, noatime, soft-updates)
/dev/md2 on /var/log (ufs, local, noatime, soft-updates)
/dev/md3 on /var/tmp (ufs, local, noatime, soft-updates)
/dev/md4 on /var/spool (ufs, local, noatime, soft-updates)
 
This was most helpful:
use iostat -I -x to see how much data was written till boot (kw/i)

What does kw/i stand for? I am doing a clone of a machine.

Code:
root@APU2FS:~ # iostat -I -x
                        extended device statistics
device           r/i         w/i         kr/i         kw/i qlen   tsvc_t/i      sb/i
mmcsd0        1684.0       134.0      31179.5       2304.5    0       11.3       6.3
md0             57.0        56.0        248.5        737.0    0        0.0       0.0
md1             66.0        77.0        340.5        909.0    0        0.0       0.0
md2             60.0        86.0        232.5       1141.0    0        0.0       0.0
md3             52.0        34.0        172.5        481.0    0        0.0       0.0
md4             52.0        34.0        172.5        481.0    0        0.0       0.0
ada0           536.0    809104.0      15033.5   50989351.0    0      184.4     163.2
ada1           530.0    809104.0      14714.5   50989351.0    0      191.3     170.2
pass0            0.0         0.0          0.0          0.0    0        0.0       0.0
pass1            0.0         0.0          0.0          0.0    0        0.0       0.0

The memory disks are defiantly working. Saving me some life.
 
Using Memory Disks did not work out so well. Had to roll back a bunch.

I decided to go another route for the OS.
I have an empty slot in my APU2. Add another controller for a SATA DOM.
Maybe gmirror a pair of SATA DOM if the APU2 power circuit can take it.
I also considered USB drives but went deluxe.
 
I found some 4GB SLC USB-DOM for cheap. Hopefully they fit inside inside the APU Chassis.

I was considering running a 4GB USB DOM and 4GB SD-Card in a gmirror.
Both are dog slow and around 20MB/sec.
Will be an interesting test. I like that I could pull out the sd-card for a backup card.
 
Send syslog to a remote system - most writes on such "configure and forget" systems are to logfiles anyways. That being said - if you don't crank up logging to insane levels, any flashdrive should be capable of lasting several years with writes to logfiles and even a small dhcp server writing leases.
The by far worst application, which kills flash cards (or USB drives) within a few months is databases. avoid them like the plague (which is also a good standard to go by in general, IMHO...)

I'm running a small gateway with OpenBSD on an Edgerouter 4 from a USB flash drive. No special configuration in regards to reducing writes; besides normal logging and vnstat it runs DHCP and a caching/recursive unbound resolver for the local network behind it and it is running 24/7 since ~mid 2019.
The drive is a normal sandisk cruzer fit (the stubby one), so nothing special or "enterprise grade". I have a spare one lying around and the machine is backed up every night, so I really don't care if that drive fails (TBH I expected it to fail on a yearly basis...)
 
Here is my general observation on /var directories on mfs.

It seems this is better suited to client machines. Servers need to have files in /var saved.
I considered writing a script to merge everything back to disk at shutdown. Too much complexity.
 
The drive is a normal sandisk cruzer fit (the stubby one),
I like those for that purpose. Except wasting a jack. I have several myself.
They do get hot when you write an image to them.
APU is USB short already. So an internal header USB-DOM was better for me..
USB and SLC with SMART. 25 bucks for 4GB. I can sleep well.
 
Wow now you make we wonder. I think inside USB header is only USB2. If I use external jack it is USB3.....
 
Back
Top