The Linux/dev/shm directory is used to optimize

Source: Internet
Author: User
Tags tmp folder

we often df–th check the disk capacity in daily operation, so what is the role of /dev/shm ?

$ df-th

File system type capacity used available % mount point

/dev/sda2 ext3 57G 32G 23G 59%/

/dev/sda5 ext3 476G 341G 111G 76%/var

/dev/sda1 ext3 190M 29M 153M 16%/boot

/dev/sdb1 ext2 1.8T 1.2T 584G 67%/ext

tmpfs tmpfs 20G 9.5G 11G 49%/dev/shm


The /dev/shm is in memory, not on disk. Because the /dev/shm exists in memory, the speed is definitely better than the disk.

/dev/shm is not an immediate use of memory, but rather a method of consuming memory if needed. In the above example, the value of the/dev/shm setting is 20G, and we see that the data that has been written to 9.5G is used to consume 9.5G of memory.

 

The /dev/shm uses the tmpfs file system, which has the following advantages :

1. fast speed.

2. Dynamic allocation: Write more data,/dev/shm occupy more memory, delete data in /dev/shm , then reduce memory consumption. Not so good for the full use of memory.

 

/dev/shm Another feature: After the system restarts and after /dev/shm is mounted, the data in the/dev/shm disappears.

 

/DEV/SHM The default value is half of memory, and sometimes increases /dev/shmas needed, such as the value in the set memory_target in Oracle exceeds the The size of the /dev/shm .

 

To Modify the /dev/shm size:

1.vim/etc/fstab

The original is this:

tmpfs/dev/shm tmpfs defaults 0 0

modified as follows, that is, 20G

tmpfs/dev/shm tmpfs defaults, size=20000m 0 0


2. effective after re- Mount/dev/shm

# Mount-o Remount/dev/shm

or umount/dev/shm .

Mount/dev/shm


See if it takes effect with df–th

 

You can also use the following method

# mkdir/mnt/tmp

# mount-t Tmpfs-o size=256m,mode=1777 tmpfs/mnt/tmp

 

 

Problem Solving:

Sometimes you may encounter a situation where /dev/shm cannot unload

# UMOUNT/DEV/SHM

umount:/dev/shm:device is busy.

 

treated with fuser

# FUSER-KM/DEV/SHM

# UMOUNT/DEV/SHM

# MOUNT/DEV/SHM

 

fuser Command

-k:kill processes accessing the named file (kills all processes that are accessing the specified file

)

- m indicates the file system or block device (in Mount state) where the specified file resides. All processes that access the file system are listed.


First, create a TMP folder in/dev/shm and then bind to the actual/tmp

#mkdir/dev/shm/tmp

#chmod 1777/dev/shm/tmp

#mount –bind/dev/shm/tmp/tmp (–bind)

The Linux/dev/shm directory is used to optimize

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.