[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: RAM DRIVE



On Sat, 4 Nov 2000, Vinod Pathangay wrote:

> hi
> 
> how to create a "RAM DISK" / equivalent??
> My program needs frequent access to disk files...
> So im thinking of putting the whole directory in RAM to speed
> up i/o...

===============================================================
[root@tachyon /root]# mke2fs /dev/ram0
mke2fs 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
1024 inodes, 4096 blocks
204 blocks (4.98%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
1024 inodes per group

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done
[root@tachyon /root]# mount -t ext2 /dev/ram0 /mnt/floppy/
[root@tachyon /root]# ls -la /mnt/floppy/
total 14
drwxr-xr-x    3 root     root         1024 Nov  4 03:19 .
drwxr-xr-x    6 root     root         1024 Oct 23 12:00 ..
drwxr-xr-x    2 root     root        12288 Nov  4 03:19 lost+found
[root@tachyon /root]# 
===============================================================

The size (of 4M) is fixed in the kernel. I guess the only way to change
it is to recompile the kernel.

And, btw, you need not see performance improvements when you use RAM disk.
(I don't remember the exact details .. I read this in some doc.)

The Linux kernel tries to optimise operations by buffering as much data as it
can. That means, all frequently accessed data is kept in memory anyways.
Using RAM disk somehow can lead to lower performance because you will reduce the
amount of available RAM for buffering.

Basically, buffering in Linux is quite good. If you have a large amount of memory,
and some files which are accessed frequently, better let the kernel handle them.
It does quite a good job.

hth.

--
jaju