Tmpfs File System in Linux (/dev/shm)

Source: Internet
Author: User
Tags php session

Tmpfs File System in Linux (/dev/shm)

Introduction

/Dev/shm/is a device that uses the tmpfs file system. It is actually a special file system. In redhat, the default size is half of the physical memory, and mkfs format is not required for use.

Tmpfs is a memory-based Virtual File System on Linux/Unix systems. Tmpfs can use your memory or swap partition to store files (that is, its storage space is in virtual memory, and the VM is composed of real memory and swap ). Therefore, tmpfs stores temporary files. It has the following two advantages: 1. The size of the dynamic file system. 2. tmpfs uses the file system created by VM, which is certainly fast. 3. Data loss after restart.

When a file in tmpfs is deleted, tmpfs dynamically reduces the file system and releases VM resources. In LINUX, temporary files of some programs can be placed in tmpfs, the tmpfs features faster than the hard disk speed to improve system performance. In practical applications, setting this file system for specific application requirements can improve application read/write performance. For example, placing the squid cache directory in/tmp and the php session file in/tmp, put the socket file in/tmp, or use/tmp as the cache device for other applications

 

Temporary modification of/dev/shm size

# Mount-o size = 1500 M-o nr_inodes = 1000000-o noatime, nodiratime-o remount/dev/shm

Mount-t tmpfs-o size = 20 m tmpfs/tmp for temporary mounting

 

Configuration Enabled on startup

You can define the size in/etc/fstab.

Tmpfs/dev/shm tmpfs, defaults, size = 512 m 0 0

Tmpfs/tmp tmpfs defaults, size = 25 M 0 0

After modification, mount-o remoount/dev/shm will take effect.

 

Mkdir/dev/shm/tmp (bind the new directory under/dev/shm/to/tmp, then/tmp uses the tmpfs File System)

Chmod 1777/dev/shm/tmp

Mount -- bind/dev/shm/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.