Ram device with TmpFS
In the last post I’ve showed you how to set up a ram device using ramdisk (e.g. /dev/ram0). Now I’ll show you how to create a ram device with tmpfs. This is especially necessary if you are on a VServer and therefore can’t increase the size of the ramdisk.
TmpFS
This is how you mount a tmpfs volume with 128MB space:
mkdir -p /mnt/tmp
mount -t tmpfs -o size=128m tmpfs /mnt/tmp
If you don’t set the size, it will use 50% of the available memory. You can set the size as a normal value (size=128[k,m,g]) or as a percentage value (size=20%).
If you want to see if it worked or how much of the device is used, use the command df -k
.
In my opinion, this is the best method to set up a ram device. There is also ramfs, on which tmpfs is based on, but I don’t recommend it.
Don’t forget that you will loose all the data on the ram device if the computer reboots or crashes, so make sure you do regular backups.
For more information, check out this link: