Discussion Locked

Linux and RAM drive

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I need to create a RAM drive and to redirect writing processes to it, like /tmp and /var directory. How to do this ?

5 replies

by embassy_16

A drive? Lets call it a device. Description: Lets call it RAM. This is a block device that will access the ram disk in raw mode. Command to creat this device:

mknod -m 660 /dev/ram b 1 1
chown root:disk /dev/ram

Then I would create a link to this new device to redirect your files.

ln -s /tmp or /var

Hope this helps you out.

by spidererrol

If you are using a 2.4.x kernel ("uname -r" will display the current version), then you can use tmpfs: "mount -t tmpfs -o size=64M none /tmp" this will create a RAM only filesystem, which will take up no more than 64Mb of physical memory, and mount it on to your "/tmp" directory.

CAUTION: Always specify the size option, and leave enough memory for you system to run in! tmpfs will absorb all you memory if you let it, and lock up your system.

Also note that tmpfs will never be swapped out to disc - it will only use real memory.

New processes will write to this filesystem just as they would any other.

This discussion is closed to new replies.