Use of Ramfs and Tmpfs

Source: Internet
Author: User
Use of Ramfs and Tmpfs-general Linux technology-Linux programming and kernel information. The following is a detailed description. For the tmpfs documentation system, type: # mount tmpfs/dev/shm-t tmpfs-o size = 32 m

Add the equivalent function of the command to/etc/fstab. It should be like this: tmpfs/dev/shm tmpfs size = 32 m 0 0

Ramfs, as its name implies, is a memory file system that works on the VFS layer. It cannot be formatted. Multiple files can be created, and the maximum memory size can be specified during creation. If Ramfs has been compiled into the kernel in Linux, you can easily use Ramfs. Create a directory and load Ramfs to the directory.

# Mkdir-p/RAM1
# Mount-t ramfs none/RAM1

By default, Ramfs is limited to up to half of the memory size. Maxsize

(In kbyte.

# Mkdir-p/RAM1
# Mount-t ramfs none/RAM1-o maxsize = 10000

A ramdisk with a maximum memory usage of 10 MB is created.

Tmpfs is a virtual memory file system. It is different from the traditional ramdisk implemented in the form of Block devices and from the Ramfs for physical memory. Tmpfs can use physical memory or swap partitions. In the Linux kernel, virtual memory resources are composed of physical memory (RAM) and swap partitions. These resources are allocated and managed by the virtual memory subsystem in the kernel. Tmpfs is used to "deal" with the virtual memory subsystem. It sends a request page to the virtual memory subsystem to store documents. It is the same as other request pages in Linux, I don't know whether the page allocated to myself is in memory or in SWAp partition. Tmpfs is the same as Ramfs, and its size is not fixed, but dynamically increased or decreased with the required space. When using tmpfs, you must first select "Virtual memory filesystem support" when compiling the kernel, and then load the tmpfs file system.

# Mkdir-p/mnt/tmpfs
# Mount tmpfs/mnt/tmpfs-t tmpfs

To prevent tmpfs from using too many memory resources and causing system performance degradation or crashes, you can specify the maximum size limit of the tmpfs document system during loading.

# Mount tmpfs/mnt/tmpfs-t tmpfs-o size = 32 m

The tmpfs document system created above sets its maximum size to 32 MB. Whether using ramfs or tmpfs, you must understand that once the system is restarted, their content will be lost. So those things can be stored in the memory document system according to the specific situation of the system.

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.