tmpfs in debian 13

KrawallKurt

Member
Dec 18, 2023
41
4
13
Hi,
I recently upgraded to PVE 9 - I know, a bit late to the party, but better late than never ;-)
As written in the upgrade guide I realized that /tmp is now a tmpfs with size 50% of RAM.

- What's a good size for the PVE host /tmp dir? Does PVE ever write there or can it also be disabled?
- Also, I saw that there is a /dev/shm which is 50% of the RAM size, too. Can this be problematic? Should it be limited? Can it even be limited?
- Is it okay to run `systemctl mask tmp.mount` to disable the /tmp tmpfs?
- Do I have to set the /tmp size in every Debian 13 container separately?

Cheers
 
- What's a good size for the PVE host /tmp dir? Does PVE ever write there or can it also be disabled?


50% is fine. This size is just the max size, it isn't reserving 50% of ram in case you write a file to /tmp, it will use memory for files as they are written, and free the memory again when they are deleted. The size is the limit where the program writing the data gets a "no free space" error.

I don't know that PVE itself uses /tmp (I suspect it does), but the OS under the PVE programs definitely does use it. It's rare to use very much space in /tmp. More on that below

- Also, I saw that there is a /dev/shm which is 50% of the RAM size, too. Can this be problematic? Should it be limited? Can it even be limited?

tl;dr - Don't disable or mess with /dev/shm

/dev/shm is for shared memory (that's what shm stands for). This is often used for programs to exchange data with each other. Again it isn't much most of the time. The computer I'm typing this on is used about 9MB in /dev/shm now, but a lot of uses of that space are very short-lived. I've known programs to need tens to hundreds of MB there for just a few seconds at a time.

Just like the tmpfs in /tmp, it doesn't actually use memory until a file is written there, so while the max usage is 50% of RAM, I don't think I've ever seen it even use 1GB.

- Is it okay to run `systemctl mask tmp.mount` to disable the /tmp tmpfs?


Sure, if you want to. Programs using /tmp will work either way. It's probably only using something in the range of dozens of MB of RAM most of the time, so you might want to think about if you care enough to change it. Also consider that writing what is by definition temporary data to your OS disk is contributing to the wear. It's up to you if you consider that unnecessary wear on the drive to be a smaller concern than 10s of MB of RAM usage.

- Do I have to set the /tmp size in every Debian 13 container separately?

I wouldn't bother, but you can if you want. Most workloads won't use enough to matter.
 
  • Like
Reactions: UdoB and Johannes S
Thanks for your answer. I was just a bit worried, because I always went by the rule to not over-provision RAM. Which would be the case if the host and every LXC could in theory use 50% + the RAM that's actually allocated.