A detailed explanation of the use of Linux server/dev/shm/

Source: Internet
Author: User
Tags centos

First let's get to know, what is Tmpfs and/dev/shm/?

TMPFS is a memory-based file system on the Linux/unix system. TMPFS can use your memory or swap partitions to store files. This shows that TMPFS mainly stores the temporary files. It has the following 2 advantages:

1. The size of the dynamic file system.

2. Another major benefit of TMPFS is its lightning speed. Because a typical TMPFS file system resides completely in RAM, reading and writing can be almost instantaneous.

It also has a disadvantage TMPFS data is not retained after a reboot because virtual memory is inherently volatile. So it is necessary to do some scripting things like loading, binding operations.

TMPFS does not have durability, after restarting data does not retain, please be sure to pay attention to!!!

/dev/shm/is a device file that uses the Tmpfs file system (note: Under CentOS and Redhat, the/DEV/SHM directory is a link to the/RUN/SHM directory, under the Ubuntu system Tmpfs file system corresponds to/run/ The SHM directory can be viewed using the DF command because the/dev/shm/directory is not on the hard drive but in memory, which is called TMPFS.

The default size in Linux distributions such as Redhat/centos is half of the physical memory. For example, my virtual machine (single core, 4096M memory) allocates memory to 2048M, so/dev/shm is about 2G, view/dev/shm as follows:

Df-h

TMPFS is a memory-based file system that does not need to be initialized with MKFS when created. If I want to change the/DEV/SHM tmpfs size to 512M, modify the/etc/fstab

TMPFS/DEV/SHM TMPFS Defaults 0 0
To

Tmpfs/dev/shm Tmpfs defaults,size=512m 0 0
And then execute

Mount-o REMOUNT/DEV/SHM
It's changed.

Add:

The use and application of TMPFS (/DEV/SHM)

TMPFS is based on memory, speed is needless to say, hard disk and it can not be compared. The automatic Memory management feature in Oracle uses/DEV/SHM. In addition, if the site dimension good use of TMPFS, there will be unexpected harvest. We first build a TMP at/DEV/SHM current and bind to/tmp.

[root@ay1212111202285f63122 ~]# Mkdir/dev/shm/tmp

[root@ay1212111202285f63122 ~]# chmod 1777/dev/shm/tmp//Attention privileges

[root@ay1212111202285f63122 ~]# Mount--bind/dev/shm/tmp/tmp

[root@ay1212111202285f63122 ~]# Ls-ld/tmp

DRWXRWXRWT 2 root May 21:46/tmp

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.