I wanted to play with ram based disks in Debian 7 Wheezy and I ran into a lot on confusing articles on the topic. I turned out that the classis /dev/ramX devices are not encouraged anymore instead, there's tmpfs.
If you don't have this, create a mount point for it:
mkdir -m 1777 /ram
and mount it:
tmpfs /ram tmpfs defaults,size=2g 0 0
You have a 2G space in the ram accessible right there.
Also, if you want to keep directories synced:
vim /root/sync-memdisk.sh
#!/usr/bin/env bash
DIRS=( 'subdir1' )
TARGETS=( '/target/root1' )
ORIGINS=( '/origin/root1' )
for ((i=0; i< ${#TARGETS[@]}; i++)); do
TARGET=${TARGETS[${i}]}
ORIGIN=${ORIGINS[${i}]}
DIR=${DIRS[${i}]}
if [ ! -d "${TARGET}/${DIR}" ]; then
echo "Initial sync from ${ORIGIN}/${DIR} to ${TARGET}/"
rsync -aq ${ORIGIN}/${DIR} ${TARGET}/
else
echo "Sync from ${TARGET}/${DIR} to ${ORIGIN}/"
rsync -au --delete ${TARGET}/${DIR} ${ORIGIN}/
fi
done
Add it to cron:
*/2 * * * * /bin/bash /root/sync-memdisk.sh >/dev/null 2>&1
(Oh, by the way: this entry was written by Peter Molnar, and originally posted on petermolnar dot net.)