A ramdisk is a portion of the computer system's memory that looks like a disk based filesystem. Data on this filesystem do not have the access penalties that physical discs bring. There is no rotational latency, nor seek. For those systems that support this capability, you can use Empress as in-memory database system and create databases and do database operations in it without any configuration.
To create in-memory filesystem requires root privileges. It is not intention of Empress to show you how to configure the ramdisk in your system since every operating system has it's differences to configure the ramdisk. The System Administrator would have to be involved in this process. However, this chapter provides examples of ramdisk configuration on Linux, Solaris, HP-UX and Unixware operating systems. It may vary from version to version of the operating system.
For Linux:
Linux has ramdisk support either compiled into the kernel, or as a loadable module. The examples given here are for a current linux kernel (2.0.33 at the time of this writing). Older kernels, as far back as 1.3.48 should be able to have ramdisk support compiled in. Pre 1.3.48 kernels have a different ramdisk driver, and have to be set up differently.
Kernel Support:
To compile in ramdisk support, answer y to the question in the kernel configuration.
RAM disk support (CONFIG_BLK_DEV_RAM) [M/n/y/?]
Module Support:
To make the ramdisk module, answer M to the question in the kernel configuration.
RAM disk support (CONFIG_BLK_DEV_RAM) [M/n/y/?]
The module can be loaded with the command:
insmod rd.o
/dev Entries:
If the system does not already have /dev/ram entries for the ramdisks, the devices have major number 0, and a minor number corresponding to the device number. For example, to make /dev/ram1, one would use the command:
mknod /dev/ram1 b 0 1
Up to 16 different ramdisks may be created this way (/dev/ram0 through /dev/ram15). If more disks are required, the source code for the ramdisk driver can be changed to allow up to 255 ramdisks. The file to edit is drivers/block/rd.c in the Linux source tree.
Allocating Space:
The Linux ramdisk driver grows dynamically as more space is needed, so to allocate space all that is needed is to write into the device the amount of space necessary. An easy way to do this is to use the dd command. For example:
dd if=/dev/zero of=/dev/ram0 bs=1k count=4k
This command will allocate 4Mb of space in /dev/ram0.
Make Filesystem:
The following command will make a Linux filesystem on the previously allocated ramdisk:
mke2fs -vm0 /dev/ram0
The new filesystem is now ready to be mounted and used.
Save Filesystem:
To make a copy of the filesystem, in order to save it before a system shutdown, or for duplication, simply unmount the filesystem, and use dd to make a filesystem image. The command:
dd if=/dev/ram0 of=ram0.image bs=1k count=4k
This will dump the filesystem on /dev/ram0 to the file ram0.image. In order to restore the filesystem, just dd it back to a ramdisk, and mount it.
dd if=ram0.image of=/dev/ram0 bs=1k count=4k
Linux has many different distributions, like RedHat, Debian, Slackware, and some dozen more. Each one sets up the kernel and modules differently. The ramdisk may or may not be available. This would be up to the System Administrator to determine.
For the system that has ramdisk compiled into the kernel, this is what you need to do:
dd if=/dev/zero of=/dev/ram0 bs=1k count=4k mke2fs -vm0 /dev/ram0 mount /dev/ram0 /mnt/ramdisk
Every one of these steps requires root privileges, so the System Administrator would have to be involved in this.
For Solaris:
In Solaris a ramdisk may be created by mounting the special tmpfs filesystem. The command:
mount -F tmpfs -o size=32M swap /mnt/ramdisk/
mounts a 32Mb ramdisk onto the mountpoint /mnt/ramdisk.
For HP-UX:
For Unixware: