The way it works is simple. You create a folder to be your "RAM drive" - this is the directory that will be stored in RAM. Then you mount the directory as a "tmpfs" and specify the amount of system memory this new RAM drive will occupy. If you want to copy a file or work with a data file from a script in the RAM drive, place it in this directory and work with it the same way you would normally.
Here's the commands to create a directory, then mount it as a tmpfs (RAM drive).
mkdir -p /home/user/Desktop/ramdrive
mount -t tmpfs -o size=500M,mode=0777 tmpfs /home/user/Desktop/ramdrive
As you can see, the mounted RAM drive is 500Mb, and set to 777 mode (accessable and executable by anyone) - once the RAM drive is dismounted, all files within it are gone. Make sure to copy them out when you're done using it.
You can also drastically increase the speed at which Apache serves up your web pages using this method.
To test this on your LAMP create the RAM drive inside /var/www and test the speed of loading those pages as compared to files read from the hard disk.
Computer Biology
No comments:
Post a Comment