Temporary filesystems
There are always some files that have a short lifetime or have no significance after a reboot. Many such files are put into /tmp
, and so it makes sense to keep these files from reaching permanent storage.
The temporary filesystem, tmpfs
, is ideal for this purpose. You can create a temporary RAM-based filesystem by simply mounting tmpfs:
# mount -t tmpfs tmp_files /tmp
As with procfs
and sysfs
, there is no device node associated with tmpfs
, so you have to supply a placekeeper string, which is tmp_files
in the preceding example.
The amount of memory used will grow and shrink as files are created and deleted. The default maximum size is half the physical RAM. In most cases, it would be a disaster if tmpfs
grew to be that large, so it is a very good idea to cap it with the -o
size parameter. The parameter can be given in bytes, KiB (k
), MiB (m
), or GiB (g
), like this, for example:
# mount -t tmpfs -o size=1m tmp_files /tmp
In addition to /tmp
, some...