Use the ramdisk File System in linux

Source: Internet
Author: User

What is RamDisk? A RamDisk is a part of the memory space you use as a hard disk partition. In other words, you assume that the memory is a hard drive and you store files on it. It is to improve the read/write speed, because you know that the memory I/O speed is N times the hard disk's 5 million ah !).

Sample Code: Create a ramdisk and mount it

# Create a mount point:

Mkdir/tmp/ramdisk0

# Create a filesystem:

Mke2fs/dev/ram0 # or: mkfs-t ext2/dev/ram0

# Mount the ramdisk:

Mount/dev/ram0/tmp/ramdisk0

If the formatting of ramdisk fails, your kernel does not support ramdisk. The Kernel configuration option is CONFIG_BLK_DEV_RAM.

* Execute df-k/dev/ram0 and how much space you actually use.

* Do not place any uncopied data in this region. If you have modified the Directory and need to keep the changes, you can back up the directory in some ways.

Set a cron process. Make it check for file changes every 10 minutes and back up these changes

* The default ramdisk size is 4 Mb = 4096 blocks. When you perform mke2fs, you can see the size of your ramdisk.

* To use ramdisk, you must obtain Kernel support or load it into the system as a module. The Kernel configuration option is CONFIG_BLK_DEV_RAM. The advantage of compiling ramdisk Into A loadable module is that you can re-determine the size of ramdisk during loading.

* A cool practice is to use a computer with 1g memory and use M as "/tmp ". if you have many processes using "/tmp", this will increase your system speed. At the same time, the items in the/tmp directory will be deleted when the system restarts. This is a good thing.
 

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.