How can I create a hybrid /tmp partition initially utilising a percent of my spare RAM and then switching to disk?
From what I have read, /tmp by default utilises up to half of your RAM. On a machine with only 2-4GB of RAM, this is a quick way to end up with a denial of service or malfunctioning applications expecting sufficient free size in /tmp.
I want to have /tmp initially use ~25% of my free RAM, and once that is full, begin using a file or partition on disk. The idea being small operations wouldn’t get slowed down waiting for disk space.
I understand that this might already happen due to the swap file/partition existing, but that means all applications would be forced to use swap space by that point.
My best guess for getting this to work right now would be an empty EXT4 partition and a EXT4 formatted RAM disk setup in RAID0, then mounted as /tmp.
Surely there is a better way to do this smoothly?
About this post
- Posted
- Archived
- Score
- 3 · 100% up
- Kind
- Text
- ID
- ozy7dd
10 comments
Unless your system use case is something almost pathological... don't try and be too clever. Let Linux manage memory.
Just create a decent sized swap partition or file in case of.short term need.
My thoughts too.
I’ll give it a go. My use case though between my desktop and server setup does need this level of security to mitigate malicious actors though.
Hardening your desktop is not how you reduce the threat surface. A $50 SBC running minimal Linux does that. (Don't use a Raspberry Pi - but there are other SBCs with two real gig Ethernet ports).
Allow nothing but ssh and returned data in.
Put your servers in separate zones, protected as required (if you are doing web hosting you need to allow 80 and 443 in, for example). The database server needs to allow DBMS connections, but only from the application servers.
At which point you rapidly get into the place where you should be using hardened commercial security equipment.
But you know all this, you're just for whatever reason trying to do it on the cheap. And the problem with cheap is that you have to be perfect every day and the bad guys only have to get lucky once.
The argument for DIY is that you're not like everybody else and most of the time they'll try the simple stuff fail and move on to the next target.
Only you can figure THAT out
Increase swappiness?
Wouldn’t that just mean my system will start using swap soon, so still push applications into swap space?
Are you experiencing a problem now, or is this a precautionary concern?
My experience is that my system never consumes more than about 2GB ram, and swap is very rarely utilized. Arch Linux, SSD, swapfile, Xfce, mainly with Firefox open.
I wanted to run GNOME for the Wayland support, so my expectations would be to have limited spare RAM. It is precautionary yes. I’ll try doing tests but I expect the results will be predictable.