my first posting here. I'm from Germany and started with LEDE just a few weeks ago, with no experience in OpenWRT yet. Had some problems with starting, but managed to solve them.
But I think about relocating specific files to RAM. Currently I run a TP-link WDR3600 with extroot (currently formatted as ext4, will be moving to f2fs soon, as f2fs 1.8.0 is out now and already installed) and start learning how to configure asterisk. I found out that /usr/lib/asterisk/astdb.sqlite3 is frequently written to, to my understanding ext4 doesn't relocate writes to databases when records are changed only, so I suspect this to quickly wear out my extroot USB stick. Don't know if f2fs solves this problem (it should, but I am not a developer yet and don't fully understand how it works exactly). I already have a crontab entry to backup /overlay to NAS twice a week so I can quickly recover from extroot breakdown without losing too much recent changes, but think about how to really prevent this kind of breakdown by limiting write access frequency.
Question: are there any standard ways to relocate files to RAM in a reliable way, so the files are copied back to overlay on shutdown/reboot and are preserved safely in case a blackout (no proper shutdown) has occurred? It seems that running a job on startup is easy with the @reboot target in crontab, and also a regular backup (let's say every two hours) via crontab is also easy, but I found no easy way to do this on shutdown. Except modifying the start/stop procedure in /etc/init.d/asterisk, which gives me some weird feeling in the stomach.
As you just poweroff the device and don't perform a shutdown then it's going to be hard. That's the nature of an embedded device. Running a cron job is probably the best you can do.
@greybeard: thanks for your reply. My idea is to script the following way, in readable pseudocode:
(script for cronjob @reboot)
(moving to RAM)
check "firstrun": if no backup exists, create one (copy astdb.sqlite3 to astdb.sqlite3.backup)
if astdb already is a symlink, copy astdb.sqlite3.backup to /tmp, else move astdb.sqlite to /tmp and create symlink (so this checks if system has been blacked out or properly shut down and handles both cases)
(script for backup creation, 2 generations, just to be safe, cronjob periodically)
if astdb.sqlite3.backup and astdb.sqlite3.backup2 both exist, delete asttdb.sqlite3.backup2
if astdb.sqlite3.backup exists, move astdb.sqlite3.backup to astdb.sqlite3.backup2
copy /tmp/astdb.sqlite3 to astdb.sqlite3.backup
(script for shutdown)
same as script for backup creation, except step 3: copy /tmp/astdb.sqlite3 to original place (overwrite symlink with real file)
So the shutdown script is only meant to ensure that no data is lost at proper shutdown, which I expect to happen way more often than a blackout. In case "blackout" some data is lost, but not much. In case blackout happened during write operation and database file is missing, second generation backup is available, which I can restore manually (or refine script to check this case, too)
still curious
codefish
edit: targeted: have asterisk in "original state" in case scripts get lost somehow so in case "properly shut down" after reboot things work regardless of scripts.
@lucize: instead of /tmp you mean? Hmm ... makes sense, thanks for pointing this out. In fact, I don't have a separate NAS device. The LEDE router IS my NAS device - I'll investigate if the hdd I use survives being online permanently. Originally I planned to spin it down when idle, it's a Toshiba DT01ABA200 which does this automatically. Is quiet enough to be online constantly. This truly would save me from having to hack a shutdown procedure, the two cronjobs @reboot and daily would suffice.
cheers, keep on the good work on LEDE, I already love it,
@lucize: can you also show me 194 max temp? Mine stands free, without active cooling, no local heat accumulation to be expected, but I am living under a roof so things might get quite warm in summertime. In the past years I already lost two linux servers that died from summer heat (and had active cooling), so this might become crucial...
My current max temp:
194 Temperature_Celsius 0x0002 253 253 000 Old_age Always - 22 (Min/Max 21/42)
measured directly after spinup. HDD is new (one week old), the 42°C were reached after one hour in 20°C environment, so I expect temperature to go as high as 55°C on hot summer days