Setting Up a RAM Disk on a Raspberry Pi 4

CanaKit Raspberry Pi 4 (4GB) Starter Kit (Amazon Affiliate)
US: https://amzn.to/3azJgrW
UK: https://amzn.to/2JdMq9o
CA: https://amzn.to/3bwiRvY
ES: https://amzn.to/2T06LnM (similar)
FR: https://amzn.to/3cvIZrs (similaire)
IT: https://amzn.to/2Ar74Sj (simile)
DE: https://amzn.to/2AqfWHQ (ähnlich)
IN: https://amzn.to/3ey6fWj
AU: https://amzn.to/2VTUt1C
NL: https://amzn.to/3f5NdsD (vergelijkbaar)

Check for Free RAM
free
Remove Swap
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
sudo update-rc.d dphys-swapfile remove
sudo apt purge dphys-swapfile
Create Mount Point
sudo mkdir -p /mnt/ramdisk
Change Permissions
sudo chown -R pi:pi /mnt/ramdisk
Create RAM Disk
sudo mount -osize=2G -t tmpfs tmpfs /mnt/ramdisk
Benchmark
cd /mnt/ramdisk
dd if=/dev/zero of=temp.txt bs=1M count=1024
dd if=temp.txt of=/dev/null bs=1M count=1024
Unmount Ram Disk
sudo umount /mnt/ramdisk
Make Ram Disk Automatic on Boot
sudo nano /etc/fstab
tmpfs /mnt/ramdisk tmpfs defaults,noatime,mode=755,uid=pi,gid=pi,size=2g 0 0

Type control-o to save and control-x to exit.

Test fstab
sudo mount -a

Leave a comment

Your email address will not be published. Required fields are marked *