Can we set the size in the following syntax as percentage instead of static size?

example from /etc/fstab

tmpfs  /var/work   tmpfs   size=100g   0 0

lets say we have ram memory with 120g , we can set the size to used 100g from the ram as mentioned above

but is it possible to set for example 80% in size instead of static value - is it possible?


`tmpfs  /var/work   tmpfs   size=80%   0 0`   ?
| improve this question | | | | |

From the kernel docs for tmpfs:

tmpfs has three mount options for sizing:

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
           since the OOM handler will not be able to free that memory.
nr_blocks: The same as size, but in blocks of PAGE_SIZE.
nr_inodes: The maximum number of inodes for this instance. The default
           is half of the number of your physical RAM pages, or (on a
           machine with highmem) the number of lowmem RAM pages,
           whichever is the lower.

These parameters accept a suffix k, m or g for kilo, mega and giga and
can be changed on remount.  The size parameter also accepts a suffix %
to limit this tmpfs instance to that percentage of your physical RAM:
the default, when neither size nor nr_blocks is specified, is size=50%
| improve this answer | | | | |
  • so we can for example to define size=90% , in that case is it mean it will used 90% of RAM and each 1% that higher from 90% is used the disk ? – yael Mar 23 at 5:17
  • No. You can define size=90%, then the total size of that tmpfs mount will be 90% of the size your RAM. There is no usage of disk. – muru Mar 23 at 5:21
  • so what happens if I set size=90% , and tmpfs used all 90% and more ? – yael Mar 23 at 5:23
  • from my understanding when tmpfs reached 90% , then any >90% will used the swap – yael Mar 23 at 5:27
  • Not sure where you got that understanding from. Here's an example: RAM 20GB, swap 10GB, and a tmpfs mount on /foo with size=90%. Then you can only put 90% of 20GB = 18GB worth of data in /foo. You can't put any more, because that is the limit. It doesn't matter how much swap you have. – muru Mar 23 at 5:32

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.