Skip to content

Using a RAM disk in Linux

Mounting RAM disk

Mounting on demand.

sudo mkdir -p /mnt/ramdisk

sudo mount -t tmpfs -o size=512m tmpfs /mnt/ramdisk

Mounting at boot time

Edit /etc/fstab.

sudo vi /etc/fstab

Add following line

tmpfs       /mnt/ramdisk tmpfs   nodev,nosuid,noexec,nodiratime,size=1024M   0 0

Verify fstab using:

sudo mount -a

UnMounting RAM disk

Unmounting on demand.

sudo umount /mnt/ramdisk