I hope many of you will agree that sometimes it’s really good idea to have some small amount of RAM mounted as a filesystem. It may be necessary when running some bash or perl script that handles, say, thousands of small files so it’s much more effective not to waste computer resources on reading/writing data on hard disk but keep those files directly in memory. This idea is known as Virtual RAM Drive or ramdisk and can be setup in Ubuntu or almost any other Linux distribution using the following commands under root (to become root in Ubuntu use
sudo -s“):"
# mkdir /tmp/ramdisk; chmod 777 /tmp/ramdisk
# mount -t tmpfs -o size=256M tmpfs /tmp/ramdisk/
where 256M is amount of RAM you wish to allocate for ramdisk. It’s clear that this value should be less than amount of free memory (use “free -m
“). BTW, if you specify too many MBs for ramdisk Linux will try to allocate it from RAM and then from swap so resulting performance would be very poor.
Beginners to the different linux kernels will find this article outlining the different versions of linux at Businesswebhostingplans.com very useful.
1# mkdir /tmp/ramdisk; chmod 777 /tmp/ramdisk
2# mount -t tmpfs -o size=256M tmpfs /mnt/tmpfs/
what is the purpose of line 1, if we mount ramdisk on /mnt/tmpfs on line 2?
why would there be ram0 -ram15 in /dev why would you need to make more how do you edit these?
Thanks for a handy tip! You saved my ass!
I am noöbe at linux commands..can someone put a correct code as trying to execute line 1&2 gives error. also, I have 4GB RAM, so how can I use most of (or atleast 1GB) for ramdisk? Thanks all.
@liver2
Maybe it is only because you don’t have the permissions to make a directory, just type ‘sudo’ at the beginning of each line and enter the password required.
I look at this and want to do it. One thing, I have no idea where you type this. Lots of instructions, but where do I type these instructions exactly. Many thanks.
Nice.. work
My question.. howto get the ramdisk to be made at boot-Up
I see these files in /dev/shm. They are modified everyday. What are these?
pulse-shm-1187254147 pulse-shm-3643037261 pulse-shm-726713703
pulse-shm-1327229993 pulse-shm-3776639608
pulse-shm-3419994561 pulse-shm-46789500 each one is 67.1mb. Opened them with Leafpad and Wordpad but could see nothing. Empty. How can I delete them?
I would like to use mdadm to create a RAID1 array (mirror) with two components:
– a regular block (disk) device, –write-mostly
– a RAM-disk
My system has oodles of RAM. So the idea is to put frequently used executables on this array, so that:
– they are speedily retreived from RAM;
– changes are persistent
Questions:
– is this a crazy idea?
– If not, how do I create the required block RAM device, one that mdadm will accept?
Have you tried to export a directory using iscsi and connect to it from the same machine? It’s hard but I think it could be the way