Tmpfs File System in Linux (/dev/shm)
Introduction
/Dev/shm/is a device that uses the tmpfs file system. It is actually a special file system. In redhat, the default size is half of the physical memory, and mkfs format is not required for use.
Tmpfs is a memory-based Virtual File System on Linux/Unix systems. Tmpfs can use your memory or swap partition to store files (that is, its storage space is in virtual memory, and the VM is composed of real memory and swap ). Therefore, tmpfs stores temporary files. It has the following two advantages: 1. The size of the dynamic file system. 2. tmpfs uses the file system created by VM, which is certainly fast. 3. Data loss after restart.
When a file in tmpfs is deleted, tmpfs dynamically reduces the file system and releases VM resources. In LINUX, temporary files of some programs can be placed in tmpfs, the tmpfs features faster than the hard disk speed to improve system performance. In practical applications, setting this file system for specific application requirements can improve application read/write performance. For example, placing the squid cache directory in/tmp and the php session file in/tmp, put the socket file in/tmp, or use/tmp as the cache device for other applications
Temporary modification of/dev/shm size
# Mount-o size = 1500 M-o nr_inodes = 1000000-o noatime, nodiratime-o remount/dev/shm
Mount-t tmpfs-o size = 20 m tmpfs/tmp for temporary mounting
Configuration Enabled on startup
You can define the size in/etc/fstab.
Tmpfs/dev/shm tmpfs, defaults, size = 512 m 0 0
Tmpfs/tmp tmpfs defaults, size = 25 M 0 0
After modification, mount-o remoount/dev/shm will take effect.
Mkdir/dev/shm/tmp (bind the new directory under/dev/shm/to/tmp, then/tmp uses the tmpfs File System)
Chmod 1777/dev/shm/tmp
Mount -- bind/dev/shm/tmp