Create a RAM Disk (tmpfs) in Raspberry Pi 3
“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.
Edit the fstab file using your favourite editor (e.g. vi)
Add the following line to /etc/fstab to create a 400MB RAM Disk
tmpfs /var/tmp tmpfs nodev,nosuid,size=400M 0 0
Execute the following command to mount the newly created RAM Disk
To verify the RAM Disk is created and mounted successfully, execute the following command
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.