Pfsense ramdisk usage
-
Since I installed pfsense (full version) on a 16GB mSATA SSD installed on an APU2C4, I removed the swap file during installation and opted to use RAM Disks for /tmp and /var. Knowing how RAM Disks work, is it recommended to have the pfsense unit plugged in a backup (UPS) power in case of power loss and so that the ramdisk contents can be flushed to disk?
Does pfsense only flush content during a reboot or a shutdown? Of course, I'm more concerned of the /var contents especially for the packages. Or would you recommend not using RAM Disks altogether as write failures are not so much of a concern with modern SSD's nowadays?
I'm also planning on using squid and lightsquid. So if I use RAM Disks, should I move the squid cache from /var/squid/cache to /squid/cache (on SSD) to avoid potential issues?
I really need your input guys. Thanks.
-
The contents of RAM disks are not saved to permanent storage at any point. Specific pieces are, such as RRD files and DHCP leases.
If you put a squid cache on your SSD you may as well not even use RAM disks, and that will cause far more writes than you'll save by using /tmp and /var in RAM.
If it's a high quality SSD, you likely do not have anything to worry about.
-
Oh I see. So what happens to /var/db then? I thought that directory is required for packages?
Well, the default squid cache location is /var/squid/cache. What do you exactly mean by "that will cause far more writes than you'll save by using /tmp and /var in RAM"?
This is the SSD: http://www.pcengines.ch/msata16d.htm so I'm assuming this is a modern one.
How about the swap file? Is it fine that I removed it from being installed during the installation? As long as I'm not consuming a 100% of the RAM, the system will never use the swap file anyway, right?
-
Oh I see. So what happens to /var/db then? I thought that directory is required for packages?
Package data is kept in a different spot and linked under there when you use RAM disks, so it shouldn't be a concern in most cases.
Well, the default squid cache location is /var/squid/cache. What do you exactly mean by "that will cause far more writes than you'll save by using /tmp and /var in RAM"?
The cache is going to cause a ton of writes to the disk. The point of putting /var and /tmp in RAM is to save disk writes. Putting the cache on the SSD will still subject the SSD to a ton of writes, so you're not saving much by using RAM disks while also running a squid cache off the disk.
This is the SSD: http://www.pcengines.ch/msata16d.htm so I'm assuming this is a modern one.
I'm not familiar with their current line of disks. They had some troublesome ones in the past. I'm not sure how much I'd trust that to stand up to repeated writes over time. A branded disk from a Tier 1 manufacturer like Intel would be a safer bet.
How about the swap file? Is it fine that I removed it from being installed during the installation? As long as I'm not consuming a 100% of the RAM, the system will never use the swap file anyway, right?
That's not quite as simple an answer as you might think. The OS will swap even when there is available RAM if the OS can use the RAM for more efficient tasks like caching process/data/disk. It is true, however, that you won't see a failure without swap if you never consume all the RAM.
-
I see what you mean now.
What size do you recommend for the /tmp and /var ramdisks if I decide to stay with using them? I noticed that /tmp isn't used that much even when set only to the default 40MB. It's a different story for /var though, it grows up to 100% when set to the default 60MB. I set it to 120MB now and is currently sitting at 55%. Am I still safe?
So generally, is it better to turn the swap file offย for SSD installation?
-
Impossible to recommend any given size. It's all about what the system, as you have configured it, requires. I wouldn't go less than 64MB each, 128MB really, and the more for /var the better.
Honestly though I don't even bother with that setting these days.
-
I see. When does /tmp fill up anyway? I never saw it significantly used even at 40MB.
Any disadvantages by not including swap during install?
I just noticed that I'm already at 100% with 120MB of /var ramdisk (it fills usually after 24 hours). Take note though that I have two pfsense boxes of the same exact kind (APU2C4) and they're just used for my home. The first one servers around only 10-15 devices (including mobile phones) and the other serves like only 3-5 devices so they are in no way loaded heavily. I have squid and lightsquid installed but they're both disabled and not configured yet since they were installed so that's not what's causing it to fill up for sure. How do I query which directory inside /var is the culpriut? Would "ls -l" do?