Skip to content

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?

3 points10 comments
Open on Reddit
About this post
Posted
Archived
Score
3 · 100% up
Kind
Text
ID
ozy7dd

Author

2
posts
47
comments
0
media
View profile

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.

7 points

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.

1 points

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

1 points

Increase swappiness?

1 points

Wouldn’t that just mean my system will start using swap soon, so still push applications into swap space?

1 points

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.

1 points

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.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.