RAM Disk Settings



  • I just ran into the issue that the RAM disk settings did not work after an upgrade from 2.4.4 to 2.4.5-p1 on a Netgate SG-2440. There is a closed bug which is most likely connected to this: https://redmine.pfsense.org/issues/10420

    I had RAM disk with 512 MB each (which worked great over the years). After the upgrade I got the message that it reverted to traditional storage. Trying to save the settings again gave the error: "Combined size of /tmp and /var RAM disks would exceed free kernel memory." Max. size is ~380 MB given. Lowering the values to 150 MB each it worked again. But then suddenly the max. size is larger again ~683 MB.
    So I tried to remove the RAM disks completely hoping that I could increase them again afterwards. Interestingly I ended up with a lower max. 394 MB having no RAM disks at all.

    This seems a little weird to me.
    Why did the larger RAM disk sizes (512 MB each in my case) stop to work with this version?
    Why is the displayed max RAM disk size larger with no RAM disks configured?

    Update: I just realized that an other system running on PCEnginges APU does not show this issue with version 2.4.5-p1. Which makes it even stranger.


  • Rebel Alliance Developer Netgate

    @FreeMindedCH said in RAM Disk Settings:

    Why did the larger RAM disk sizes (512 MB each in my case) stop to work with this version?

    Previous versions allowed the kernel to overcommit kernel memory. The disks created OK but you could never have filled them up without exhausting kernel memory and crashing. The newer base OS prevents that.

    @FreeMindedCH said in RAM Disk Settings:

    Why is the displayed max RAM disk size larger with no RAM disks configured?

    Anything that consumes kernel memory will reduce the available amount. That also includes the RAM disks themselves and their contents. The GUI tries to calculate things properly to account for that, but it's not perfect.



  • @jimp thanks for the clarification!
    What RAM disk sizes would you recommend for a Netgate SG-2440?

    Any idea why the very same installation does not show this behaviour an a PCEngines APU?



  • @FreeMindedCH said in RAM Disk Settings:

    What RAM disk sizes would you recommend for a Netgate SG-2440?
    Any idea why the very same installation does not show this behaviour an a PCEngines APU?

    Hi,

    Why would you want to use a RAM disk?
    is it very important to have in your system....?

    in front of me a colleague described very well why it is not advisable to use
    (especially if you have little physical RAM in your system, such as 2 or 4GB on the APU MOBO)

    here is a great and detailed description of @bmeeks:

    https://forum.netgate.com/topic/155220/swap-usage

    "Using RAM disks will make your problem orders of magnitude worse! Do you know what swap is for and what it actually is?

    Swap memory is a type of temporary RAM. When there is not enough physical RAM to hold the information the currently running processes are using, the operating system will cycle currently idle sections of RAM out to a special file on the disk. So any currently loaded process that happens to be sleeping or otherwise not actively using CPU at that exact instant can have some or all of its data removed from RAM and written to the swap file on disk to free up RAM for use by another active process. Then, when that sleeping process "wakes up" and starts execution again, the operating system reads its data from the swap file and copies it back into RAM. This is an extremely slow set of processes compared to keeping the data in RAM the whole time. So usage of swap is basically to be avoided. When you start using swap, things are going to get very slow very fast.

    A RAM disk uses part of RAM to hold data that is normally written to disk. So you would be taking up even more precious RAM to act as a disk drive and thus increase the operating system's need to use the swap file. You leave the OS even less free RAM to use for processes since a RAM disk reserves some RAM to be a disk drive. RAM disks today are generally a bad idea on pfSense. I suggest you avoid using them altogether.

    As @DaddyGo mentioned, you are using some memory intensive packages. 4 GB of RAM is really not all that much for the packages you have. Are you sure you really need Squid? With the widespread use of HTTPS today, the utility of caching with Squid is reduced unless you are using some type of MITM. Squid can use a lot of disk space, too. The ntopng package can also be quite resource intensive as an Snort. So together, all those packages can give your firewall a real workout with only 4 GB of RAM available. That's why your firewall is resorting to use swap space, and it is having trouble even with that. This is because swap space is configured during pfSense installation and is a fixed size. Your error messages indicate you are exhausting your swap file space."


Log in to reply