TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:9949] How do I set up a ramdisk?



On Tue, 9 Nov 1999 schewe@tcfreenet.org wrote:

> On  9 Nov, Karl Morgan wrote:
> >      # dd if=/dev/zero of=/dev/ram bs=1024 count=2048
> > 
> > 2) Then create the filesystem on the ramdisk
> > 
> >      # /sbin/mke2fs -vm0 /dev/ram 2048
> > 
> > 3) Then mount it wherever you like
> > 
> >      # mount /dev/ram /mnt
> > 
> 
> Why does one need the first dd?  Why not just the mkfs?  Also what does
> one need to do to free up that memory?  Just unmount it?

I remember reading that it wasn't required but it may be in the
future. I know that a ramdisk on current linux kernels only require
one to write to them in order to allocate the space. Thus the mke2fs
does the trick just fine since it writes the filesystem to the device
(/dev/ramX). Or more specifically, the following comment in rd.c

 * It also does something suggested by Linus: use the buffer cache as the
 * RAM disk data.  This makes it possible to dynamically allocate the RAM disk
 * buffer - with some consequences I have to deal with as I write this.

Just unmounting the filesystem won't deallocate the space. I tried :(
a couple times :( with 4 4Mb ramdisks (/dev/ram[0-3]). My system is
now 16Mb less :( The initrd manpage makes reference to a
freeramdisk(8) command which doesn't seem to exist anymore. The top command
shows the space being used by buff.

Just a note, it seems the maximum size of a ramdisk is 4Mb unless you are
willing to modify /usr/src/linux/drivers/block/rd.c and recompile your
kernel.

Regards - Karl