RAM DISK (Ramdisk)

Post Reply
mpskinner
Site Admin
Posts: 74
Joined: Wed Sep 20, 2017 6:52 am

RAM DISK (Ramdisk)

Post by mpskinner » Thu Nov 09, 2017 3:21 am

A RAM Disk is nothing more than storage set up in Ram that presents itself and acts exactly like a drive would. You can save and write files into a Ram disk exactly as if its was a physical drive like a hard drive or an SSD. The advantages of a Ram Disk is speed and it prevents wear and tear on physical drive incurred when data is written to them. Or read in the case of a hard drive.

Create a place for your RAM Drive

Code: Select all

sudo mkdir /mnt/RAM_disk
Make a backup of the file you edit.

Code: Select all

sudo cp /etc/fstab /etc/fstab.bak
Open fstab to edit.

Code: Select all

sudo nano /etc/fstab
and add this code to the bottom of the file. In this example I will create a 2gig RAM Drive: See the size=2G. You can change this to what your system will allow.

Code: Select all

tmpfs     /mnt/RAM_disk     tmpfs     rw,size=2G,x-gvfs-show     0 0
Your RAM Disk will be available on reboot. Or you could mount is with

Code: Select all

sudo mount -a


How to Create a RAM Disk

Give the Present User Permission to use this Directory

Code: Select all

sudo chown -R $USER RamDisk

mpskinner
Site Admin
Posts: 74
Joined: Wed Sep 20, 2017 6:52 am

Re: RAM DISK (Ramdisk)

Post by mpskinner » Wed May 15, 2019 3:52 am

Back Up Your Ram Disk

To save the Contents of the Ramdisk when you shut your computer down make a bash script to copy the contents of the Randisk to an Flash Drive.

In your /bin/ dirctory add this file

Code: Select all

sudo nano ramdiskcopy


Write this code. In this example I am copying data from my Ramdisk to a flash drive named Orange

Code: Select all

#!/bin/bash
cp -ru /mnt/Ramdisk /media/matthew/Orange/
echo "Files Saved to Orange"
I put the echo command there so you could see if your script is running.

Give the ramdiskcopy file these user permissions

Code: Select all

sudo chmod 777 ramdiskcopy

Post Reply