The technology is built into the kernel, you don't need any extra tools. In fact, you already have a few RAM disks (which you shouldn't use, they're reserved for the system), which you can see by doing
grep -w tmpfs /proc/mounts
To set up a 2GB RAM disk mounted on
/ramdisk, add the following line to
ramdisk /ramdisk tmpfs mode=1777,size=2g
Then mount the disk with the command
mount /ramdisk (this will be done automatically when you reboot).
The indicated size is a maximum, the disk only uses as much memory as the files that are on it.
You can change
/tmp to be a RAM disk. In the
/etc/fstab line above, put
/tmp rather than
/ramdisk, then reboot.
The first time you reboot after changing
/tmp to be a RAM disk, the files that were in
/tmp will be hidden. That's harmless, except that they're wasting a little disk space. You can clean them up (after you've rebooted with
/tmp on the RAM disk) by doing
mount --bind / /mnt
rm -r /mnt/tmp/* /mnt/tmp/.*
mount --bind command makes
/mnt a duplicate view of your root filesystem; but while the RAM disk now obscures
/tmp on the root view, nothing is obscuring
ADDED: You can switch
/tmp to a RAM disk without rebooting, it's just a little more complicated. Add the line to
/etc/fstab as above, then run the following commands:
mount --bind /tmp /tmp.old
ln -s /tmp.old/* /tmp/.* .
/tmp.old after your next reboot.
The reason you can't just move files from
/tmp is that some critical programs have files open in
/tmp, for example
/tmp/.X11-unix/X0 which the X server listens on and every GUI program opens when it starts. Moving a file to a different filesystem means copying it and deleting the old one, so you would end up with the X server still listening on
/tmp.old/.X11-unix/X0 but X clients contacting
/tmp/.X11-unix/X0 in vain. On a server, you might get away with a move if you're careful.