ramdisk

CREATE A RAM DISK (TMPFS) IN RASPBERRY PI 3

June 25, 2017 jleung 0 Comment Raspberry Pi

“tmpfs” writes to RAM instead of the SD card on the Raspberry Pi. It is very easy to use, fast, and avoid writing too much on the SD card. Excessive writing to the SD card will break it easily. Please remember that all data on that RAM Disk will be lost after reboot.

Setup Procedures (Please use root)

Create the temporary directory for the RAM Disk.

sudo mkdir /var/www/html/control

sudo chmod 777 /var/www/html/control

Edit the fstab file using your favourite editor (e.g. vi)

sudo vi /etc/fstab

Add the following line to /etc/fstab to create a 400MB RAM Disk

tmpfs /var/www/html/control tmpfs nodev,nosuid,size=10M 0 0

Execute the following command to mount the newly created RAM Disk

mount -a

To verify the RAM Disk is created and mounted successfully, execute the following command

df -h

and you should see something like this

Filesystem Size Used Avail Use% Mounted on /dev/root 29G 1.5G 26G 6% / devtmpfs 458M 0 458M 0% /dev tmpfs 462M 0 462M 0% /dev/shm tmpfs 462M 6.2M 456M 2% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 462M 0 462M 0% /sys/fs/cgroup tmpfs 400M 0 400M 0% /var/tmp /dev/mmcblk0p1 63M 22M 42M 35% /boot

Temporary files can now be write to /var/tmp partition. This blog will share more use cases on this RAM Disk.