Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|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

2 Answers 2

up vote 2 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

share|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

Step 1: Consider what exactly was already developed by your whole body

Red-colored Cap produces of sixteen ramdisks automatically, although there're not necessarily "active" or making use of almost any RAM. It listings products ram0 : ram 19, however solely ram0 : ram15 are usually usable automatically. To check on these block products out there, utilize the using get:

[root]# ls -l /dev/ram*
lrwxrwxrwx 1 root root four Jun 12 00: thirty-one /dev/ram -> ram1

Step 2: Improve ramdisk size

Ramdisk size can be controlled by way of command-line solution which is passed on the kernel in the course of trunk. Since GRUB could be the default bootloader intended for Red-colored Cap 9, I'll transform /etc/grub.conf while using brand new kernel solution. The actual kernel solution intended for ramdisk size can be: ramdisk_size=xxxxx, where xxxxx could be the size indicated with 1024-byte hindrances. Can do for you I'll complement /etc/grub.conf for you to configure of sixteen MB ramdisks

Step 3: Data format the particular ramdisk

There' no requirement for you to file format the particular ramdisk as a journaling file process, therefore most of us only will utilize the common ext2 file process. When i solely desire to use one particular ramdisk, so i is only going to file format /dev/ram0:

Step: Make a attach place along with attach the particular ramdisk

Today you have formatted the particular ramdisk, you need to make a attach place for doing this. Then you can definitely attach your current ramdisk along with work with it. Many of us will use the particular service /mnt/rd because of this operations.

Activity 5: Make use of the ramdisk

Since it has been designed, you can easlily replicate, shift, get rid of, revise, along with quantity data files round the ramdisk as provided that these people wound up with the actual physical hard drive partiton. This is actually the fantastic position intended for a peek at decrypted GPG or possibly OpenSSL data files, in addition to a fantastic position for just a crank out data files which is to be encrypted. Right after your own host is definitely run lower, a lot of record linked with data files designed round the ramdisk have left.

In order to unmount this ramdisk, merely enter your next:

[root]# umount -v /mnt/rd
/dev/ram0 umounted.

And other linux related news: http://www.kingsizevps.com/hosting/linux-vps-hosting

share|improve this answer
    
This doesn't address the question though - unmounting a ramdisk does not deallocate the memory: if you remount it the data is still where you left it. As per the accepted answer, freeramdisk does the trick. –  RobM May 12 '13 at 16:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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