If you do not have a lot of spare ram, it is recommended to use 'tmpfs' instead of 'ramfs', as tmpfs uses Swap when the available RAM starts to run out, whereas ramfs does not of course, dipping into swap loses the performance benefits of RAM, so it's a little pointless unless you have a lot of spare RAM.

+

If you do not have a lot of spare ram, it is recommended to use 'tmpfs' instead of 'ramfs', as tmpfs uses Swap when the available RAM starts to run out, whereas ramfs does not. Of course, dipping into swap loses the performance benefits of RAM, so it's a little pointless unless you have a lot of spare RAM.

==Example usage==

==Example usage==

Revision as of 19:03, 8 August 2011

A ramdisk is a portion of RAM utilised as a disk. Many distributions use /dev/ram for this, however Arch does not have a /dev/ram so we must use /etc/fstab to create ramdisks. The most important thing to remember about a ramdisk is that it is stored in RAM and thus volatile. Anything stored on a ramdisk will be lost if the computer completely seizes up, or loses power. Therefore, it is necessary to save the contents of your ramdisk to the harddrive if you want to save them.

Contents

Why use one?

As a ramdisk is stored in RAM, it is much faster than a conventional filesystem. So, if you need to manipulate files at high speed, a ramdisk could be the best solution. Popular choices include /tmp, /var/cache/pacman, or /var/lib/pacman, although I'm sure you could think of many others.

How to create a ramdisk

To create a ramdisk, you must treat it as any other mounted filesystem. You must first pick and create a location for it to reside on, and then add it to your /etc/fstab file as follows:

none /path/to/location ramfs 0 0

If you do not have a lot of spare ram, it is recommended to use 'tmpfs' instead of 'ramfs', as tmpfs uses Swap when the available RAM starts to run out, whereas ramfs does not. Of course, dipping into swap loses the performance benefits of RAM, so it's a little pointless unless you have a lot of spare RAM.

Example usage

The files that have been edited are /etc/fstab, /etc/rc.local, and /etc/rc.local.shutdown to store /tmp, /var/cache/pacman, and /var/lib/pacman in RAM, and sync them to disk before shutting down. Portions of the files not relevant to the topic at hand have been removed to save space