Tmpfs is too big for me. How to decrease its footprint?

Hello community,
I am quite a happy user of DietPi on a friendlyElec R2S device.

My only concern ist that it has only 1GB of RAM and half of it is reserved for tmpfs.
I wonder how to decrease tmpfs to a smaller footprint.

Any help would be appreciated :blush:

I made it :+1:
/etc/fstab was my friend :face_with_hand_over_mouth:

Btw, a tmpfs does not reserve the RAM, but uses it only on demand. There are multiple other tmpfs mounts (df -h) with a summed size larger than total RAM, which is totally fine as they never actually fully use that size concurrently. I recommend to leave the /tmp size as it was (50% of RAM + swap), especially on low RAM devices. Otherwise dietpi-software installs might fail, which often download and extract to, sometimes compile in /tmp tmpfs to reduce disk writes.

Very interesting :- :+1:
I have disables swp and htop shows me this:

I wonder what it means as it did not change when I decrease tmpfs in fstab. This looks quite crouded to me so I tried to decrease tmpfs.

On the other hand cat /proc/meminfo gives me an inactive space of 650MB but only a free space of 79MB while running my software. I fear the 79MB might not be enough in the long run. And what is the difference between free and available :face_with_raised_eyebrow:

Would you please explain that to me so I will get a bit smarter?

MemTotal: 999584 kB
MemFree: 79788 kB
MemAvailable: 392600 kB
Buffers: 12244 kB
Cached: 453576 kB
SwapCached: 0 kB
Active: 152764 kB
Inactive: 650516 kB
Active(anon): 31060 kB
Inactive(anon): 408712 kB
Active(file): 121704 kB
Inactive(file): 241804 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 20 kB
Writeback: 0 kB
AnonPages: 337564 kB
Mapped: 167080 kB
Shmem: 102312 kB
KReclaimable: 22508 kB
Slab: 57172 kB
SReclaimable: 22508 kB
SUnreclaim: 34664 kB
KernelStack: 3728 kB
PageTables: 7456 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 499792 kB
Committed_AS: 1337212 kB
VmallocTotal: 133143592960 kB
VmallocUsed: 15104 kB
VmallocChunk: 0 kB
Percpu: 1344 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
CmaTotal: 131072 kB
CmaFree: 40392 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB

Linux uses available memory to cache reads and writes from resp. to filesystem, to speed those up and reduce actual disk I/O. These are the blue (buffer) and yellow (cache) parts of the memory usage bar in htop. So it’s expected to be nearly full, hence “MemFree” very low. Important is only that “MemAvailable” is sufficiently large resp. the green part of the bar not too large on common usage.

The size of any tmpfs has no effect on RAM usage as long as you do not actually store files into them to use that space.

1 Like

Thank you for you in depth explanation. I got smarter :+1: