Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Using RAMdisks for /tmp and /var - Traffic Totals gone after power loss - Which setting to choose to write to disk?

    Scheduled Pinned Locked Moved General pfSense Questions
    13 Posts 5 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      Finger79
      last edited by Finger79

      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:

      1. Simply disable the RAM Disk for /var
      2. Manually create a cron job (or other automation) that copies that database somewhere safe in the event of a system reboot.
      JonathanLeeJ 1 Reply Last reply Reply Quote 0
      • stephenw10S
        stephenw10 Netgate Administrator
        last edited by stephenw10

        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

        1 Reply Last reply Reply Quote 1
        • F
          Finger79
          last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • stephenw10S
            stephenw10 Netgate Administrator
            last edited by

            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.

            F 1 Reply Last reply Reply Quote 0
            • F
              Finger79 @stephenw10
              last edited by

              @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.

              1 Reply Last reply Reply Quote 0
              • stephenw10S
                stephenw10 Netgate Administrator
                last edited by

                That was just the reporter. Not sure why it was set to that. Added a target version.

                M 1 Reply Last reply Reply Quote 1
                • M
                  Mission-Ghost @stephenw10
                  last edited by

                  @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...

                  F 1 Reply Last reply Reply Quote 1
                  • stephenw10S
                    stephenw10 Netgate Administrator
                    last edited by

                    Hmm, doesn't seem like it would be that tricky. Looks like 3 files required to replicate what rrd does for example... 🤔

                    1 Reply Last reply Reply Quote 1
                    • F
                      Finger79
                      last edited by Finger79

                      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 ?

                      1 Reply Last reply Reply Quote 0
                      • stephenw10S
                        stephenw10 Netgate Administrator
                        last edited by

                        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.

                        W 1 Reply Last reply Reply Quote 0
                        • W
                          Waqar.UK @stephenw10
                          last edited by Waqar.UK

                          @stephenw10

                          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.

                          1 Reply Last reply Reply Quote 1
                          • JonathanLeeJ
                            JonathanLee @Finger79
                            last edited by

                            @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.

                            Make sure to upvote

                            1 Reply Last reply Reply Quote 0
                            • F
                              Finger79 @Mission-Ghost
                              last edited by

                              @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.

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.