Configure Ramdisk snapshot for your Linux instance.

Source: Internet
Author: User
Give your Linux Device Ramdisk snapshot-general Linux technology-Linux programming and kernel information. The following is a detailed description. Recently, I upgraded my laptop's memory from MB to 2 GB in one fell swoop. The pleasure of using the notebook is unmeasurable. The previous usage habits have been completely broken. Now, we are not stingy about how much software we need to use can be opened, with the excellent caching technology of the Linux system, the faster the computer is used, the less you want to restart.

In addition, I thought that, if the "duck-filling" method of using 2 GB memory seems to be too backward, I would use the advantages of the Linux architecture to make full use of the memory. So I thought of Ramdisk!

Ramdisk: memory is used as the disk. The speed of memory is second only to CPU cache and display card memory in computer storage devices. However, the speed of hard disks in computers is obvious to all.

Use a part of the memory capacity as a virtual disk and place the data that needs to be read and exchanged frequently. This is the best use of the memory.

Let's set up Ramdisk step by step.

The Linux 2.6 kernel generally supports 16 Ramdisk devices by default. You can run the following command to check the number of available ramdisks in Linux:

Ls/dev/ram *

Generally, we will not use up 16 of them. Here we only use one.

Just like using any blank device, we need to format the "disk" into the desired format. Here we still use the most common ext3:

Sudo mkfs. ext3/dev/ram0

Formatting to ext3 is almost instantaneous, because the memory is formatted. We will ask, what is the disk capacity? We can see from the output information, for example: blocks = 67108864, which is about 64 MB. Therefore, I can create a total of 16 × 64 = Mb virtual memory.

After formatting, mount it and use it now.

Create a folder anywhere you want, such as my:/hom/tualatrix/ramdisk, and then execute the command to mount it:

Sudo mount/dev/ram0 ~ /Ramdisk/

Mounted ~ Don't worry, you can't use it. Because ramdisk ownership is root, we need to convert it into our own:

Sudo chown tualatrix: tualatrix ~ /Ramdisk

Finally, the Ramdisk is ready, and now you can operate it as you like a normal folder.

But what can I do with a 64 MB virtual disk? Can you scale up the capacity?

Sorry, apart from formatting multiple/dev/ram sub-directory mounting, I have not found a way to increase the capacity of a single Ramdisk partition.

However, this Ramdisk is really strong! If you make good use of it, it will certainly help you, because it is very fast!

I tested the performance of hdparm (sudo hdparm-tT/dev/ram0), and the speed of buffered disk reads reached 842 MB/s, while my hard disk was only 32 MB/s, the gap is almost 30 times.

How to Use It depends on everyone ~ For example, mounting the/tmp directory to Ramdisk is also a good idea!

But don't forget that the memory data will disappear during shutdown. If you need to save the data, you can write a script for dumping the data and put it in/etc/init. d/, then link to/etc/rc0.d (this directory script is called when the Ubuntu system is shut down), then write a script to automatically format and mount Ramdisk and call data, and put it in/etc/init. d/, and then link to/etc/rc2.d (which is called by default when the Ubuntu system is started) to facilitate automatic mounting and dumping.

The specifics depend on the flexible application of everyone, and friends with large memory do not take actions quickly.

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.