Tips for using tmpfs on Linux

  

tmpfs is a memory-based file system that can be used after installation. The following small series will give a detailed introduction to the use and size of Linux tmpfs. Interested friends can Come to understand.

tmpfs introduce

tmpfs is a virtual memory file system, rather than a block device. It is a memory-based file system. It does not need to be initialized with mkfs when it is created.

Its biggest feature is that its storage space is in VM (virtual memory), and VM is managed by the vm subsystem in the Linux kernel.

The size of the VM under Linux consists of RM (Real Memory) and swap. The size of RM is the size of physical memory, and the size of Swap is determined by itself.

Swap is the memory space virtualized by the hard disk, so its read and write speed is much slower than RM (Real Memory). When a process requests a certain amount of memory, the kernel vm subsystem finds no When there is enough RM, some unusable data in the RM will be exchanged into Swap. If you need to re-use the data, then exchange them from Swap to RM. If there is enough physical memory, you can not divide the Swap partition.

The VM consists of two parts, RM+Swap, so the maximum storage space of tmpfs is (The size of RM + The size of Swap). But for tmpfs itself, it doesn't know if the space it uses is RM or Swap, all of which is managed by the kernel's vm subsystem.

The default size of tmpfs is half of RM. If your physical memory is 1024M, the default size of tmpfs is 512M

In general, it is less than the physical memory size.

The size of the tmpfs configuration does not really occupy this memory. If there is no file under /dev/shm/, the memory it occupies is actually 0 bytes; if it is at most 1G, put it inside With 100M files, the remaining 900M can still be used by other applications, but the 100M memory it occupies will not be re-divided by system recycling.

When deleting files in tmpfs, the tmpfs file system driver dynamically reduces the file system and frees up VM resources.

############################################################################################### >

The Automatic Memory Management feature in Oracle uses /dev/shm.

LINUX can put temporary files of some programs in tmpfs, and use tmpfs to improve system performance faster than hard disk.
Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved