User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

RAM drive??

Wed Dec 05, 2012 12:15 am

Is it possible to have a mountable RAM drive device and how do I define one i.e. to use 1MB of system RAM??

Richard S.

Tafkas
Posts: 49
Joined: Sun Sep 16, 2012 11:15 pm
Contact: Website

Re: RAM drive??

Wed Dec 05, 2012 12:47 am

You can just use /run/shm for that. It is already built-in.

NickMon68
Posts: 28
Joined: Fri Nov 18, 2011 9:18 pm

Re: RAM drive??

Wed Dec 05, 2012 9:54 am

What are you using the Ram drive for ?

Poor little Pi not got enough as it is !
:D

Would a USB stick not be more useful

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: RAM drive??

Wed Dec 05, 2012 10:40 am

I want an area of disk space where I can constantly change the contents i.e. webcam image refresh, access log files for web server etc.
Since flash memory has limited write cycles before going bad having a RAM drive would eliminate this problem because the writes are in RAM only.

After some searching on Google I found the following that works on my PI:
mkdir /ram
mkfs -q /dev/ram1 1024
mount /dev/ram1 /ram

RAM drive now exists in /ram if you need RAM drive again after a reboot just repeat the same commands except for mkdir /ram

Now if only I had the PI 512MB model B I would have loads more RAM to play with. :)

While on the subject of RAM there appears to be other RAM devices present i.e. /dev/ram1 /dev/ram2 /dev/ram3 ... /dev/ram15.

Can anyone explain the difference between /dev/ram1 and /dev/ram2 ??

Richard S.

steev
Posts: 87
Joined: Fri Jan 27, 2012 5:08 pm

Re: RAM drive??

Wed Dec 05, 2012 12:18 pm

They are just multiple ramdisks you can use. Each one is 16 MB by default, but the memory isn't reserved until you format them.

I think these days it's usually better to use tmpfs or ramfs, though:
http://www.thegeekstuff.com/2008/11/ove ... s-on-linux

Like Tafkas said above, there is already a tmpfs on /dev/shm/ which you can use.

NickMon68
Posts: 28
Joined: Fri Nov 18, 2011 9:18 pm

Re: RAM drive??

Thu Dec 06, 2012 2:29 pm

is /dev/shm loaded on the pi ?

If so its a Ram disk, lost on boot..

Return to “Raspbian”