Using RAMdisks for /tmp and /var - Traffic Totals gone after power loss - Which setting to choose to write to disk?
-
Using the Traffic Totals add-on but also using the RAM Disk option to minimize writes. UPS battery failed so I'm in the process of replacing it with big, beefy ones (DIY modification project). In the meantime, lost power twice today for a minute each and the router also lost power and came back successfully, but Traffic Totals reset to 0.
Periodic RAM Disk Data Backups
- RRD Data
- DHCP Leases
- Log Directory
- Captive Portal Data
In System --> Advanced --> Miscellaneous which one of these applies to Traffic Totals? Is it RRD Data? Log Directory? Or if it's none of the above, then that means I would need to turn off the RAM Disk for /var, but that's a last resort.
Thanks.
Edit:
The SQLite database is located in /var/db/vnstat/vnstat.db so if none of those 4 options to periodically backup RAM Disk to disk apply, that leaves me with two options:
- Simply disable the RAM Disk for /var
- Manually create a cron job (or other automation) that copies that database somewhere safe in the event of a system reboot.
-
A feature request to add backing that up might be best: https://redmine.pfsense.org/
If there isn't one already.Otherwise that data will be lost if you have /var as a ramdisk.
Steve
Edit: There is: https://redmine.pfsense.org/issues/11797
Add comments there -
I can't be the only one using both Traffic Totals and a RAMdisk. Is there a way to get some love on this bug?
-
Add comments to the bug there.
I use that combo here but I guess I just don't hit it often enough for it to be an issue.
-
@stephenw10 I already did back in April. I don't have anything else to add. It's assigned to "John Cornwell" as of 2 years ago, but I have no idea who that is on the Netgate team.
-
That was just the reporter. Not sure why it was set to that. Added a target version.
-
@stephenw10 this is inauspicious--aka--kicking the can down the road...again and again...from the redmine bug:
Updated by Jim Pingle about 1 year ago Plus Target Version changed from 24.03 to 24.07 #5 Updated by Jim Pingle 10 months ago Plus Target Version changed from 24.07 to 24.08 #6 Updated by Jim Pingle 6 months ago Plus Target Version changed from 24.08 to 24.11 #7 Updated by Jim Pingle 6 months ago Plus Target Version changed from 24.11 to 25.01 #8 Updated by Jim Pingle 4 months ago Plus Target Version changed from 25.01 to 25.03 #9 Updated by Jim Pingle about 2 months ago Plus Target Version changed from 25.03 to 25.07
I found no caveats in the manual about traffic totals being incompatible with ram disk, so I tried ram disk in attempt to further mitigate SSD wear in my 4200...only to have it fill up, blow up, and lock up the router requiring a hard reboot. Niiice.
So I turned it off, but this would be a nice fix. But the history isn't supporting it even showing up in 25.07...
-
Hmm, doesn't seem like it would be that tricky. Looks like 3 files required to replicate what rrd does for example...
-
I haven't dabbled in the pfSense codebase, but I did see a Netgate developer solve a related issue by re-locating where another file/db is saved. So applying that here, perhaps move
/var/db/vnstat/vnstat.db
to/usr/local/pkg/vnstat/vnstat.db
so this way we can have our cake and eat it too (still have a RAMdisk for /var but have the Traffic Totals database stored to non-volatile disk)...I don't know if that's a possible solution or not.
Edit: It looks like
/var/db/pkg
saves to "zfs" instead of "tempfs," so perhaps the solution is as simple as moving the Traffic Totals database from/var/db/vnstat/vnstat.db
to/var/db/pkg/vnstat/vnstat.db
? -
Mmm, I'm not sure how much data is written by traffic totals but it would be better to have that data included in the RAM disk backup IMO. Most users enable RAM disks to minimise drive writes.
pfBlocker does that for example but uses quite a complex solution.
-
True, I enable a RAM disk, my system has 8GB RAM and I run pfgblocker. my SSD which I have been using for almost 10 years, thankfully on 96% health. It is a TLC kingston SATA drive.
-
@Finger79 some veritas and Symantec systems I use to work on years ago used a capacitor to write the data when power was lost. It was fat like 3 c batteries in a row. But it was for this very issue what ever was in ram needed to go directly to disk as fast as possible.
-
@Mission-Ghost said in Using RAMdisks for /tmp and /var - Traffic Totals gone after power loss - Which setting to choose to write to disk?:
@stephenw10 this is inauspicious--aka--kicking the can down the road...again and again...from the redmine bug:
Updated by Jim Pingle about 1 year ago Plus Target Version changed from 24.03 to 24.07 #5 Updated by Jim Pingle 10 months ago Plus Target Version changed from 24.07 to 24.08 #6 Updated by Jim Pingle 6 months ago Plus Target Version changed from 24.08 to 24.11 #7 Updated by Jim Pingle 6 months ago Plus Target Version changed from 24.11 to 25.01 #8 Updated by Jim Pingle 4 months ago Plus Target Version changed from 25.01 to 25.03 #9 Updated by Jim Pingle about 2 months ago Plus Target Version changed from 25.03 to 25.07
I found no caveats in the manual about traffic totals being incompatible with ram disk, so I tried ram disk in attempt to further mitigate SSD wear in my 4200...only to have it fill up, blow up, and lock up the router requiring a hard reboot. Niiice.
So I turned it off, but this would be a nice fix. But the history isn't supporting it even showing up in 25.07...
Thanks for the thread bump. I'm relieved I'm not the only person who's noticed this. I wonder if there is just a development staffing shortage, because even in the forums there's silence.
Are there any how-to guides on getting started with pfSense development? I have the GitHub repo starred. I just don't have a clue how to set up a development environment to be able to tackle some bugs myself.