A ramdisk is like a disk partition but running directly from the system’s RAM. All data read and written will be faster, and as drawback all data will be erase when you reboot the system. Some Linux distributions use this kind of file system to avoid killing the media, for instance instead of using a files system on a SD Card you can use a ramdisk.
If you need to create a partition of this type here is explained how to do it.
Creating the ramdisk with mount
To create the ramdisk in /tmp/ramdisk type the following commands:
chmod 1777 /tmp/ramdisk
mount -t tmpfs -o size=8G tmpfs /tmp/ramdisk/
Then you can check it using df or mount:
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 9.2G 533M 8.2G 6% /
udev 7.9G 4.0K 7.9G 1% /dev
tmpfs 3.2G 308K 3.2G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 7.9G 0 7.9G 0% /run/shm
/dev/sda1 268M 50M 204M 20% /boot
/dev/sda6 9.2G 552M 8.2G 7% /usr
/dev/sda7 19G 172M 18G 1% /tmp
/dev/sda9 490G 560M 464G 1% /var
/dev/sda8 6.5G 143M 6.0G 3% /usr/local
tmpfs 8.0G 0 8.0G 0% /tmp/ramdisk
Here you can see that the mount command creates a ramdisk by specifying tmpfs as the file system type, the size is given with the size option, and the mount point (which has all permission and the sticky bit enabled).
Creating the ramdisk from the /etc/fstab
If you want changed to be permanent you must add the following line to the /etc/fstab as shown below:
# RAM diskramdisk
/tmp/ramdisk tmpfs mode=1777,size=8g
Here the device specified is ramdisk, the mount point is /tmp/ramdisk, the file system type is tmpfs, all permission are set for user, groups and other and the sticky bit is enabled, and the ramidisk’s size is defined by the size option.