From LQWiki
Jump to navigation Jump to search

tmpfs is a file system that stores all files in virtual memory (meaning it will also use the swap space). It adjusts the actual memory size it uses to fit the files, so it doesn't used a fixed amount of memory. It allows to specify a maximum size with the size option when (re)mounting. The default size is half the available RAM.

It is mainly used to implement POSIX shared memory in Linux, by mounting a tmpfs file system on /dev/shm. It is also often mounted on /tmp, /var/tmp or some other personal tmp directory to increase performance of these often used directories. It is also used by udev (which mounts a tmpfs on /dev/).

Example usage


mounting a tmpfs on /tmp with max size of 512 Megabytes and permissions of 1777:

mount -t tmpfs tmpfs /tmp -o size=512M,mode=1777

the equivalent entry in the fstab

none /tmp tmpfs size=512M,mode=1777 0 0

Increase the size

Increase the size of a ramdisk:

mount -t tmpfs tmpfs /tmp -o size=2000M,mode=1777,remount

This increases the ramdisk's size to 2000M. No file is destroyed.