Use RamDisk in Ubuntu

Source: Internet
Author: User
By default, Ubuntu uses half of the memory as ramdisk space. The mount point is/dev/shm. The file type tmpfs/dev/shm is not entirely RamDisk. If it uses more than half of the computer's RAM, it will start to eat SWAP. In addition, the unused parts will be automatically released to the system. Using ramdisk, you can place the cache in it, which will prolong the hard disk life and increase the computer speed by 1, modify the size of the/dev/shm directory in the ramdisk operation. 1) view the size.

By default, Ubuntu uses half of the memory as ramdisk space. Mount point:/dev/shm file type: tmpfs

/Dev/shm is not entirely RamDisk. If it uses more than half of the computer's RAM, it will start to eat SWAP. In addition, the unused parts are automatically released for use by the system.

Ramdisk can be used to store the cache, which can prolong the hard disk life and increase the computer speed.

1. Modify the ramdisk operation.

Resize the/dev/shm directory
1) view the size
Df-h/dev/shm

2) modify the size
Vi/etc/fstab
Tmpfs/dev/shm tmpfs ults, size = 4096 M 0 0

The size parameter can also use G as the unit: size = 1G.

Without this line, you can add and modify the size of www.linuxidc.com.

3) remount
Umount/dev/shm
Mount/dev/shm

4) view the modified size
Df-h/dev/shm

2. Set the/tmp directory to RamDisk.

Basically, you only need to run the following command to bind/tmp to/dev/shm.

Mkdir/dev/shm/tmp
Chmod 1777/dev/shm/tmp
Mount -- bind/dev/shm/tmp

※Note: Why is mount -- bind used instead of ln-s soft link? The reason is that the/tmp directory is not deleted.

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.