How to Use tmpfs in RHEL/CentOS 7.0

Source: Internet
Author: User

How to Use tmpfs in RHEL/CentOS 7.0

Today, let's talk about a file system tmpfs in CentOS 7, which writes all files and folders to the virtual memory instead of actually writing them to the Virtual File System on the disk. This means that all content in tmpfs is temporary, and the content will be lost after tmpfs is uninstalled, the system is restarted, or the power is cut off. Technically, tmpfs places all the content in the internal cache of the kernel and adjusts the size to accommodate the file, and can exchange unwanted pages from the swap space.

By default, CentOS uses tmpfs for the following purposes:

  1. # df –h

  • /Dev-directory containing device files for all devices
  • /Dev/shm-including shared memory allocation
  • /Run-used for system logs
  • /Sys/fs/cgroup-for cgrpups, a kernel feature for specific process restrictions, control, and audit resource utilization

Obviously, it can also be used as the/tmp directory. You can use the following two methods to do this:

 

Use systemctl to enable tmpfs in/tmp

You can use the systemctl command to enable tmpfs in the tmp directory. First, use the following command to check whether this feature is available:

  1. # systemctl is-enabled tmp.mount

This will display the status at the beginning (if not enabled), you can use the following command to enable it:

  1. # systemctl enable tmp.mount

This allows the system to control the/tmp directory and mount a tmpfs File System under the directory.

 

Manually mount the/tmp File System

You can add the following line in/etc/fstab to manually Mount tmpfs under/tmp.

  1. tmpfs /tmp tmpfs size=512m00

Run this command.

  1. # mount –a

This should display tmpfs in df-h, and it will be automatically mounted at the next restart.

 

Create tmpfs now

If you need to create tmpfs in a folder for some reason, you can use the following command:

  1. # mount -t tmpfs -o size=1G tmpfs /mnt/mytmpfs

Of course, you can specify the desired size and mount point in the size option, as long as you remember that it is a valid directory.

Introduction and use of tmpfs in Linux

Modify the tmpfs size in Oracle Linux (OEL) and make it take effect

Potential problems with using the tmpfs File System for MySQL tmpdir

Differences between tmpfs and ramfs in Linux

Fedora 18 will use tmpfs by default when/tmp

Instructions on how to modify/etc/fstab to make tmpfs take effect in Oracle Linux 6.1

Via: http://linoxide.com/file-system/use-tmpfs-rhel-centos-7-0/

Author: Adrian Dinu Translator: geekpi Proofreader: wxy

This article was originally translated by LCTT and launched with the Linux honor in China

This article permanently updates the link address:

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.