TMPFS file system for Linux CentOS

Source: Internet
Author: User

The size of the VM under Linux is made up of RM (Real memory) and swap, and the size of the RM is the size of the physical RAM, and the size of the swap is up to you. Swap is a virtual memory space through the hard disk, so it is much slower to read and write than RM (Real memory), why do we need swap? When a process requests a certain amount of memory, such as when the kernel's VM subsystem finds that there are not enough RM, it will swap some of the infrequently used data in the RM into swap, if it needs to re-use the data and swap them from swap to RM. If you have large enough physical memory, you do not need to partition the swap partitions at all.


With the instructions above, you should know what the storage space VM used by TMPFS is, right? As mentioned earlier, the VM consists of two parts, so the maximum storage space of TMPFS is up to (the size of RM + the size Ofswap) Rm+swap. But for TMPFS itself, it does not know whether the space it uses is RM or swap, which is managed by the kernel's VM subsystem.

How to use TMPFS?

#mount-T Tmpfs-o size=20m tmpfs/mnt/tmp

Above this command assigned a maximum of 20m VM to the/mnt/tmp directory, with the DF command to see, indeed/mnt/tmp mount point display size is 20m, but TMPFS one advantage is that its size is the actual storage capacity and change, in other words, if/mnt/ There is nothing in the TMP directory, TMPFS does not occupy the VM. The above parameter 20m just tells the kernel that this mount point maximum available VM is 20m, if not add this parameter, tmpfs default size is RM half, if your physical memory is 128M, then tmpfs default size is 64M,


Do TMPFS have any shortcomings?

Of course, because its data is in the VM, so the power outage or after you uninstall it, the data will be lost immediately, this may be the reason it is called TMPFS. However, this is not a shortcoming in fact. What's the use of that TMPFS?


Use of TMPFS

Since TMPFS uses a VM, it is definitely faster than the hard drive, so we can use it to improve the performance of the machine.


#mount-T Tmpfs-o size=2m tmpfs/tmp

The above command assigns a maximum of 2m VMS to/TMP.

Since the/tmp directory is where temporary files are placed, we can use TMPFS to speed up, because the files in the/tmp directory may be in use before they are mounted, so the system may not function properly after mounting. No matter, just add the following statement to the/etc/fstab

Tmpfs/tmp Tmpfs size=2m 0 0

After restarting the computer, everything is OK.


TMPFS file system for Linux CentOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.