Creating a RAMdisk on Ubuntu

In this article I will give an example of creating a disk in RAM.

Create a directory where we will mount the disk:

sudo mkdir /mnt/ramdisk 

Mount the disk in this directory:

sudo mount -t tmpfs -o rw,size=1G tmpfs /mnt/ramdisk

We check:

df -h

You can unmount the disk with the command:

sudo umount /mnt/ramdisk

In order for the disk to be automatically mounted when the operating system starts, it must be specified in the /etc/fstab file, just in case, we will make a backup copy of this file and open it in any text editor:

sudo cp -v /etc/fstab /etc/fstab.backup
sudo nano /etc/fstab

Let’s specify the line:

tmpfs  /mnt/ramdisk  tmpfs  rw,size=1G  0   0

Restart the server and make sure the disk is mounted:

sudo reboot

See also my articles:
Installing Memcached
Test iops using fio

Leave a comment

Leave a Reply