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.
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.
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
none /tmp ramfs defaults 0 0 none /mnt/ramdisk ramfs defaults 0 0
chmod 777 /tmp touch /etc/ramdisk.sh echo "#!/bin/dash" >> /etc/ramdisk.sh echo "cd /var/ && tar cf abs.tar abs/" >> /etc/ramdisk.sh echo "cd /var/cache/ && tar cf pacman.tar pacman/" >> /etc/ramdisk.sh echo "cd /var/lib/ && tar cf pacman.tar pacman/" >> /etc/ramdisk.sh echo "mkdir /mnt/ramdisk/var/" >> /etc/ramdisk.sh echo "mkdir /mnt/ramdisk/var/cache/" >> /etc/ramdisk.sh echo "mkdir /mnt/ramdisk/var/lib/" >> /etc/ramdisk.sh echo "mv /var/abs /mnt/ramdisk/var" >> /etc/ramdisk.sh echo "mv /var/cache/pacman /mnt/ramdisk/var/cache" >> /etc/ramdisk.sh echo "mv /var/lib/pacman /mnt/ramdisk/var/lib" >> /etc/ramdisk.sh echo "ln -s /mnt/ramdisk/var/abs /var/abs" >> /etc/ramdisk.sh echo "ln -s /mnt/ramdisk/var/cache/pacman /var/cache/pacman" >> /etc/ramdisk.sh echo "ln -s /mnt/ramdisk/var/lib/pacman /var/lib/pacman" >> /etc/ramdisk.sh echo "ln -s /tmp /mnt/ramdisk/tmp" >> /etc/ramdisk.sh echo "chmod 777 /mnt/ramdisk/tmp" >> /etc/ramdisk.sh echo "rm /etc/ramdisk.sh" >> /etc/ramdisk.sh chmod +x /etc/ramdisk.sh /etc/ramdisk.sh &
echo "Saving contents of ramdisk to harddrive" rm /var/abs rm /var/cache/pacman rm /var/lib/pacman mv /mnt/ramdisk/var/abs /var mv /mnt/ramdisk/var/cache/pacman /var/cache mv /mnt/ramdisk/var/lib/pacman /var/lib