I've been playing with Linux RAMDISKs, as in the block device /dev/ram0. I understand that when I first start writing to one of these devices some RAM is allocated to it.

How do I free the memory used by, say, /dev/ram0? Put another way: how do I indicate to the Linux kernel that I'm done and it can reclaim whatever resources are held by /dev/ram0?

link|improve this question
Did you mount the ram disk to something like /mnt/ramdisk? – Mike Keller Aug 5 '11 at 14:57
I used mkfs /dev/ram0 and then mounted it, did some experiments (testing how my app copes with out of disk-space conditions) and unmounted it. But that doesn't free the memory that backs /dev/ram0. – RobM Aug 5 '11 at 19:42
feedback

1 Answer

up vote 1 down vote accepted

Unless you format the ramdisk something along the lines of

mke2fs -m 0 /dev/ram0

The ramdisks themselves don't actually occupy any memory space.

If you do format and mount a ramdisk however, the only way that I remember doing is by using freeramdisk but that was a long long time ago.

Some other resources you might want to check out:

http://e2enetworks.com/2008/10/25/linux-in-memory-filesystems-tmpfs-vs-ramdisk/

http://www.vanemery.com/Linux/Ramdisk/ramdisk.html

http://www.linuxdoc.org/HOWTO/BootPrompt-HOWTO-3.html

link|improve this answer
1  
Thanks freeramdisk does the trick. Verified by experiment while watching the output from free. – RobM Aug 5 '11 at 18:04
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.