How to reduce the tmpfs size?

because i got page allocation failure
my ram is 64M but /tmp has 29.9M so i want to reduce /tmp size
I found it https://openwrt-devel.openwrt.narkive.com/8yA4HqVn/tmpfs-tmp-size-how-to-change
is there a file where I can config it?

AFAIK, tmpfs has a "maximum" size, but will only take as much RAM as needed.

the size of filesystem can be reduced, right ? how to set the maximum to 50% of ram?

No, you can only reduce the maximum size (and the instructions are on the post you linked); the current size depends on te usage.

As @eduperez says, it only takes as much RAM as needed.
The problem arises in RAM limited devices as the useage of /tmp increases with unnecessary files. Luci creates lots of files and leaves them there, as does opkg update. Packages also will place their logs there.
This /tmp storage will take more and more RAM as files are written.

You can however change the maximum size of /tmp to some reduced value to make sure you have RAM left for processes, but this is very much a compromise and has to be done by trial and error to best suit the compromise you need to come to for your particular situation.

For example, set the /tmp ramdisk max size to 11MB:
mount tmpfs /tmp -t tmpfs -o remount,size=11000k,nosuid,nodev

When I have needed to do this, I found it best added to /etc/rc.local so it takes effect on a reboot. If you make it too small, then other things might fail eg Luci, opkg, dhcp or anything that writes to /tmp

I am sure there are other ways but at least this is quick and simple.

2 Likes