View the ramdisk size:
Fdisk-L/dev/ram0
The followingArticleTransferred from:Http://www.linuxdiyf.com/viewarticle.php? Id = 26952
1. What is ramdisk?
Ram: memory, Disk: disk, which can be used as a partition in Linux. It is called ramdisk. For files that are frequently accessed and will not be changed, you can
Placing them in memory through ramdisk can significantly improve system performance. Ramdisk works on the Virtual File System (VFS) layer and cannot be formatted, but multiple
Ramdisk. Although the cost of hard disks is getting cheaper and cheaper, ramdisk is still very useful when we want to make it more accessible.
If you have high computing speed requirements, you can increase the memory and use the ramdisk technology. A
Ramdisk assumes the memory as a hard drive and stores files on it. Assume that several files are frequently used. If you add them to the memory,ProgramHigh Speed
High because the read/write speed of the memory is much higher than that of the hard disk. Specify part of the memory to improve the overall performance, no less than replacing the new CPU. Computers like Web servers need to read and exchange a large number of specific files. Because
Therefore, creating ramdisk on the web server will greatly increase the network read speed.
Ii. How to Use ramdisk
Format a ramdisk and add it to a directory. Use "ls-Al/dev/Ram *" to list all available ramdisks *". This will list your existing available ramdisk. These ramdisks do not occupy the memory unless they are formatted. Here is an example of using ramdisk.
# Create a mount point:
Mkdir/tmp/ramdisk0
# Create a filesystem:
Mke2fs/dev/ram0
# Mount the ramdisk:
Mount/dev/ram0/tmp/ramdisk0
These three commands will create a directory for ramdisk, format ramdisk (Create File System), and load this ramdisk to "/tmp/ramdisk0 ". now you can think of this directory as a virtual partition. Using it is like using other directories.
If the formatting of ramdisk fails, your kernel does not support ramdisk. The Kernel configuration option is config_blk_dev_ram.
The default ramdisk size is 4 MB = 4096 blocks. When you perform mke2fs, you can see the size of your ramdisk. Mke2fs/dev/ram0 will generate information suitable for the following classes:
Mke2fs 1.14, 9-Jan-1999 for ext2 FS 0.5b, 95/08/09
Linux ext2 filesystem format
Filesystem label =
1024 inodes, 4096 Blocks
204 blocks (4.98%) reserved for the Super User
First data block = 1
Block size = 1024 (log = 0)
Fragment size = 1024 (log = 0)
1 block group
8192 blocks per group, 8192 fragments per group
1024 inodes per group
Run DF-k/dev/ram0 and how much space you actually use:
> DF-k/dev/ram0
Filesystem 1k-blocks used available use % mounted on
/Dev/ram0 3963 13 3746 0%/tmp/ramdisk0
So what is the trouble? When the system restarts, the region will be refreshed. Do not place any uncopied data in this area. If you have modified the Directory and need to keep the changes, you can back up the directory in some ways.
3. Change the ramdisks size.
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 when loading.
The first method. Add the following to the Lilo. conf file:
Ramdisk_size = 10000 (or ramdisk = 10000 for old kernels)
In this way, after you use the Lilo command and restart the computer, the default ramdisk size will be 10 MB. This is an example of the/etc/Lilo. conf file:
Boot =/dev/hda
Map =/boot/Map
Install =/boot. B
Prompt
Timeout = 50
Image =/boot/vmlinuz
Label = Linux
Root =/dev/hda2
Read-Only
Ramdisk_size = 10000
Specifically, I only use more than 9 MB space, and the file system will also occupy a certain amount of space.
When you compile ramdisk in the form of a module, you can determine the size of ramdisk during loading. This can also be done by modifying the/etc/CONF. Modules option settings.
Options rd rd_size = 10000
Or, specify the parameter in the command line to ismod:
Insmodrd rd_size = 10000
The following is an example of how to use such a module:
Unmount ramdisk, umount/tmp/ramdisk0.
Uninstall the module (automatically loaded during the process mentioned in the previous section), rmmod Rd
Load the ramdisk module and set its size to 20 m. insmod RD rd_size = 20000
Create a file system, mke2fs/dev/ram0
Load ramdisk, Mount/dev/ram0/tmp/ramdisk0
Advantages and disadvantages of four ramdisks
ramdisk simulates the memory as the hard disk space. No matter when you use ramdisk, you actually use the memory instead of the hard disk. There are both advantages and disadvantages in this regard. The most basic,
the biggest advantage is that you are using the memory, and everything you do will be faster, because the hard disk speed is slower than the memory speed. The biggest drawback is that if you change the content of the database server and restart the machine, all the changes are lost.