/dev/shm

Source: Internet
Author: User

The size of the Linux default (CentOS)/DEV/SHM partition is 50% of the system's physical memory, although the use of/DEV/SHM is much more efficient for file operations.
However, it is seldom used in the current release software (except for Oracle mentioned earlier) and can be viewed through LS/DEV/SHM to see if there are any files below, and if not, the current system does not use the device.

The kernel configuration in the default Linux distribution will turn on TMPFS and map to the SHM directory under/dev/. You can view the results by using the DF command.
/dev/shm/is a very useful directory for Linux because it is not on the hard disk, but in memory. Therefore, under Linux, it is not necessary to build RAMDisk, the direct use of/dev/shm/can achieve a good optimization effect. The default system will load/DEV/SHM, which is called TMPFS, some say with RAMDisk (virtual disk), but not the same. Like a virtual disk, TMPFS can use your RAM, but it can also be stored using your swap partition. And the traditional virtual disk is a block device, and requires a command such as MKFS to really use it, TMPFS is a file system, not a block device; you just install it and it's ready to use.
TMPFS has the following advantages:
1. The size of the dynamic file system,/dev/shm/need to pay attention to one is the capacity problem, under Linux, it defaults to half the size of memory, using the Df-h command can be seen. But it does not really occupy this memory, if there is no file under the/dev/shm/, it occupies the memory is actually 0 bytes, if it is a maximum of 1G, there are 100M files inside, the remaining 900M can still be used for other applications, but it occupies the 100M memory, Will never be re-partitioned by system recycling.
2. Another major benefit of TMPFS is its lightning speed. Because a typical TMPFS file system resides completely in RAM, read-write can be almost instantaneous.
3. TMPFS data is not retained after a reboot because virtual memory is inherently volatile. So it is necessary to do some scripts such as loading, binding operations.

[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root 27G 5.3G 20G 22%/
Tmpfs 1.9G 650M 1.3G 34%/DEV/SHM

The default maximum half of the memory size may not be sufficient in some cases, and the default inode count is generally higher, so you can use the Mount command to manage it.
#mount-o size=1500m-o nr_inodes=1000000-o noatime,nodiratime-o remount/dev/shm
On a 2G machine, the maximum capacity is tuned to 1.5G, and the inode number is set to 1000000, which means roughly 1 million small files can be deposited.
If you need to permanently modify the value of/DEV/SHM, you need to modify the/etc/fstab
Tmpfs/dev/shm Tmpfs defaults,size=1.5g 0 0
Mount-o REMOUNT/DEV/SHM

/dev/shm

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.