How to increase size of tmpfs file system

tmpfs is a common name for a temporary file storage facility on many Unix-like operating systems. It is intended to appear as a mounted file system, but stored in volatile memory instead of a persistent storage device. On reboot, everything in tmpfs will be lost. tmpfs is supported by the Linux kernel from version 2.4 and up. source

Some directories where tmpfs is commonly used are /tmp, /var/lock and /var/run. Do not use it on /var/tmp, because that folder is meant for temporary files that are preserved across reboots.

Tmpfs, against ramfs, is capable to swap out its content. For example, you can have as big tmpfs as you wish - if you have enough free swap space. You can have a 16GB tmpfs with a single GB of ram - although it can cause your system to a little bit of overload, similarly as if you would run a process with 16GB ram on an 1GB machine.

Modify /etc/fstab line to look something like this

# sudo vim /etc/fstab
tmpfs /dev/shm tmpfs rw,gid=105,uid=102,size=1000M,mode=0700 0 0

Update

mount -o remount tmpfs

To see the changes

df -h

Be careful not too increase it too much because the system will deadlock since the OOM (Out-Of-Memory) handler can not free up that space.

comments powered by Disqus