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.
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?
Thanks, GhostOrchid -- I fixed the typo.
Ubuntu by default already has /dev/shm mounted as tmpfs. If you really like the name /tmp/ramdisk, you can just do:
1# ln -s /dev/shm/ /tmp/ramdisk
If the name isn't all that important to you, just use /dev/shm directly.
Pingback : Links 25/3/2010: Free Software Award Winners, Red Hat’s Results Analysed | Boycott Novell
This is a seriously handy tip if you are using an SSD drive and wish to minimise the read / write access during heavy scripts.. Top! :)
why would there be ram0 -ram15 in /dev why would you need to make more how do you edit these?
Any opportunity you could suggest a good feed reader? I wish to follow your website to keep up with what you write.
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.
Pingback : Usage of a Ramdisk on Linux » Philipp Klaus's Blog
@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.
Pingback : Create a ramdisk | INDLOVU
F*ckin’ awesome things here. I’m very glad to see your article. Thanks so much and i'm taking a look ahead to touch you. Will you kindly drop me a mail?
I think this is one of the most significant info for me. And i am glad reading your article. But want to remark on few general things, The website style is great, the articles is really great : D. Good job, cheers
Strange this post is totaly unrelated to what I was looking google for, nevertheless it used to be listed at the first page. I assume your doing something right if Google likes you sufficient to put you at the first web page of a non similar search.
Pingback : Centos5 Ramdisk help
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.
system are that it gives you everything you need; you only need to present the lessons to your child.
smallqna - You type it in your shell using Terminal. On Ubuntu systems its here:
Applications (int the top left corner of task bar by default) => Accessories => Terminal.
Nice.. work
My question.. howto get the ramdisk to be made at boot-Up
You can create the script containing those ramdisk commands and then add it to startup according to this setup: http://www.ubuntuka.com/autostart-ubuntu-startup/
Correct link
Your article is rocking and knowledgeable I truly appreciate the way you write . I would like to read more from you.