Table of Contents

Ubuntu - Disk - Ramdisk - Create a Ramdisk

Create a Ramdisk

mkdir /mnt/ramdisk
mount -t tmpfs -o rw,size=240G tmpfs /mnt/ramdisk

NOTE: This mounts a ramdisk with 240GB under the path /mnt/ramdisk.

  • -t tmpfs:
    • tmpfs only uses memory when you it contains files.
    • When it is empty, it will take almost no space in RAM.
  • An alternative to tmpfs is to use ramfs.
    • tmpfs can use swap as well, whereas ramfs devices are memory only.

Verify the Ramdisk

Verify that the RAMDISK has been created.

df -h

Mount the Ramdisk automatically on system boot

Edit /etc/fstab, and add the following line to the the end of the file.

/etc/fstab
tmpfs  /mnt/ramdisk  tmpfs  rw,size=240G  0   0