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:
# 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:
# 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:
# 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.
tmpfs /tmp tmpfs size=512m00
Run this command.
# 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:
# 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: