CentOS modify tmpfs (memory file system)

Source: Internet
Author: User
By default, tmpfs is enabled for CentOS. Tmpfs uses memory. if the memory is used up, swap space is used. Adjust the tmpfs size. do not exceed the memory + swap size. If the system resources are insufficient and the memory is used up, the efficiency of tmpfs is greatly reduced when swap is used. Therefore, we recommend that you install more memory, which is not expensive. Tmpfs is a memory file system, which is similar to ramdisk in the DOS era. it can be mounted and used without mkfs or other commands for initialization.

By default, tmpfs is enabled for CentOS. Tmpfs uses memory. if the memory is used up, swap space is used. Adjust the tmpfs size. do not exceed the memory + swap size. If the system resources are insufficient and the memory is used up, the efficiency of tmpfs is greatly reduced when swap is used. Therefore, we recommend that you install more memory, which is not expensive. Tmpfs is a memory file system, which is similar to ramdisk in the DOS era. it can be mounted and used without mkfs or other commands for initialization.

# Cat/etc/fstab

LABEL =/               /Ext3  ULTS      1 1
LABEL =/home/HomeExt3  ULTS      1 2
LABEL =/boot1/BootExt3  ULTS      1 2
Tmpfs/Dev/shmTmpfs ULTS      0 0
Devpts/Dev/ptsDevptsGid = 5, model = 6200 0
Sysfs/Sys                  Sysfs ULTS      0 0
Proc/ProcProc  ULTS      0 0
LABEL = SWAP-sda3SwapSwap  ULTS      0 0

 

The tmpfs line is to enable tmpfs. The files stored in tmpfs can be read and written very quickly. after all, the memory is read directly, of course, much faster than the disk. The files in tmpfs are lost after restart. Suitable for storing session or other temporary files. The read/write speed can be greatly improved.

 

4 GB memory. The system defaults to 2 GB tmpfs space.

12 GB memory. 6 GB tmpfs space is enabled by default. That is to say, by default, half of the memory space is open for tmpfs.

You can use methods such as shm_open and shm_unlink to operate tmpfs.

View the tmpfs size:
#Df-h/dev/shm

FilesystemSizeUsed Avail Use % Mounted on
Tmpfs               2.0 GB 24 K2.0 GB 1%/dev/shm

 

Modify tmpfs size
Modify the tmpfs line in the/etc/fstab file:
Tmpfs/dev/shm tmpfs ULTS ults,Size = 8192 M0 0

 

Then reload tmpfs.

# Umount/dev/shm; mount/dev/shm; df-h/dev/shm
Filesystem          SizeUsed Avail Use % Mounted on
Tmpfs8.0 GB08.0 GB 0%/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.