By default, tmpfs is enabled for CentOS. Tmpfs uses memory. if the memory is used up, swap space is used. Adjust the tmpfs size. do not exceed the memory + swap size. If the system resources are insufficient and the memory is used up, the efficiency of tmpfs is greatly reduced when swap is used. Therefore, we recommend that you install more memory, which is not expensive. Tmpfs is a memory file system, which is similar to ramdisk in the DOS era. it can be mounted and used without mkfs or other commands for initialization.
By default, tmpfs is enabled for CentOS. Tmpfs uses memory. if the memory is used up, swap space is used. Adjust the tmpfs size. do not exceed the memory + swap size. If the system resources are insufficient and the memory is used up, the efficiency of tmpfs is greatly reduced when swap is used. Therefore, we recommend that you install more memory, which is not expensive. Tmpfs is a memory file system, which is similar to ramdisk in the DOS era. it can be mounted and used without mkfs or other commands for initialization.
# Cat/etc/fstab
LABEL =/ /Ext3 ULTS 1 1
LABEL =/home/HomeExt3 ULTS 1 2
LABEL =/boot1/BootExt3 ULTS 1 2
Tmpfs/Dev/shmTmpfs ULTS 0 0
Devpts/Dev/ptsDevptsGid = 5, model = 6200 0
Sysfs/Sys Sysfs ULTS 0 0
Proc/ProcProc ULTS 0 0
LABEL = SWAP-sda3SwapSwap ULTS 0 0
The tmpfs line is to enable tmpfs. The files stored in tmpfs can be read and written very quickly. after all, the memory is read directly, of course, much faster than the disk. The files in tmpfs are lost after restart. Suitable for storing session or other temporary files. The read/write speed can be greatly improved.
4 GB memory. The system defaults to 2 GB tmpfs space.
12 GB memory. 6 GB tmpfs space is enabled by default. That is to say, by default, half of the memory space is open for tmpfs.
You can use methods such as shm_open and shm_unlink to operate tmpfs.
View the tmpfs size:
#Df-h/dev/shm
FilesystemSizeUsed Avail Use % Mounted on
Tmpfs 2.0 GB 24 K2.0 GB 1%/dev/shm
Modify tmpfs size
Modify the tmpfs line in the/etc/fstab file:
Tmpfs/dev/shm tmpfs ULTS ults,Size = 8192 M0 0
Then reload tmpfs.
# Umount/dev/shm; mount/dev/shm; df-h/dev/shm
Filesystem SizeUsed Avail Use % Mounted on
Tmpfs8.0 GB08.0 GB 0%/dev/shm