[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to use a ramdisk?



Eric House wrote:

> The HOWTOs talk about ramdisks as part of the install process, but not
> as something I can use every day.  Assuming that I *can* have a ramdisk
> on hamm, how do I set it up?
>

The file /usr/src/linux/Documentation/ramdisk.txt contains all the info you need. If
you haven't installed the kernel sources though, here's the short version:

Here's how (assuming your kernel has ramdisk support built in):

1) Decide how big you want your ramdisk to be. Yes, you have to decide. ramdisks can
grow dynamically, but filesystems won't. Bummer, huh?

2) Now choose a ramdisk device and create the filesystem with the size you decided on.
As root:

mke2fs /dev/ram0 size-in-1K-blocks

3) Now mount, season to taste, and enjoy!

mount /dev/ram0 /mnt

Now read on for other answers...

> So far, I've:
> put 'ramdisk=2000' in my /etc/lilo.conf file (and run lilo).  dmesg tells
> me that 16 2000K ramdisks were set up, but free shows that no memory is
> consumed so I assume there's another step to making them available.
>
> I want only one, BTW. :-)

You don't need the above. That just tells the kernel to allocate one at startup. This
is only necessary if you're going to load the root into a ramdisk and mount it (like
you do during installation).

> What's next?  I'd expect to need to put something in /etc/fstab, but
> what's the device file? (/dev/ramdisk?)

/dev/ram0, /dev/ram1, /dev/ram2, etc. The number supported is compiled into your
kernel, most likely 16.

>  What if I want more than one?

1 device per ram disk.

> And what's the expected/traditional mount point?

There isn't. It's like any other block device, mount it wherever you want.

>  The fstype?

Whatever you create on it. I used ext2 above.

> Is
> there any further configuration to be done?

Nope.

> How do I use ramdisks once they're created?  Just copy my files to the
> disk and symlink to them from where they're expected to be?  What do I
> do to ensure that the files are written to (real) disk on shutdown or
> at predefined intervals?

Just like any other mounted filesystem. They are never written to disk. That's why
they call them "ram" disks. If you want a disk that actually has physical media, why
don't you use a real disk? If you're thinking to create a ram disk for performance,
don't. Linux agressively uses memory as buffer cache already, so you won't get better
performance this way.

> I'm so full of questions.  Surely there's documentation on this
> somewhere.  But: Where?

--
Jens B. Jorgensen
jjorgens@bdsinc.com



Reply to: