19

What sets the size of the tmpfs? (On my machine it resides in /dev/shm) I can see its entry in /etc/fstab, but no notation of its size. When checking with df -h, it seems to be half the size of the physical memory installed in the system. Is this the default behavior?

Also, what happens if it gets full? Does it expand dynamically forcing other running programs into swap? Does tmpfs itself moves into swap partition?

Finally, what takes priority into the memory tmpfs or applications? i.e., if I have tmpfs sufficiently full (like 40% of the physical memory) and I have programs that requires 70% of the physical memory, which one gets the priority?

18

What sets the size of the tmpfs? (On my machine it resides in /dev/shm) I can see its entry in /etc/fstab, but no notation of its size.

The kernel documentation covers this underneath the mount options:

size: The limit of allocated bytes for this tmpfs instance. The default is half of your physical RAM without swap. If you oversize your tmpfs instances the machine will deadlock

(Emphasis mine)

Also, what happens if it gets full?

As referenced above if you've committed too much to tmpfs your machine will deadlock. Otherwise (if it's just reached its hard limit) it returns ENOSPC just like any other filesystem.

Finally, what takes priority into the memory tmpfs or applications? i.e., if I have tmpfs sufficiently full (like 40% of the physical memory) and I have programs that requires 70% of the physical memory, which one gets the priority?

It's similar to the contention between programs. The pages most used will tend to be in physical memory while the least used pages will tend to be swapped out.

If you need to ensure the pages are always in physical memory you can use ramfs which is similar but is of fixed size and doesn't swap.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.