Due to the frequent writing or overwriting of data, the lifespan of an SD card is affected.
For example, it is recommended to write temporary data (e.g. sensor values for comparative calculations) to a RAM disk for applications that often contain temporary data (e.g. sensor values for comparative calculations) that are no longer needed after a restart.
Another advantage of a RAM disk is that the access (write and read) is much faster than from the SD card.
If the Raspberry Pi 4 is equipped with RAM from 1 GB upwards, it is not a problem to divert 50 or 100 MB of it for a RAM disk.
To create a RAM disk, follow these steps:
- Creating a mount point:
sudo mkdir /mnt/ramdisk
- Enter in /etc/fstab so that a RAM disk is automatically generated at startup:
sudo nano /etc/fstab
tmpfs /mnt/ramdisk tmpfs nodev,nosuid,size=50M 0 0
This allows you to store 50 MB of data on /mnt/ramdisk. After a restart, you can log in with
sudo df -h
indicate whether the RAM disk was created successfully.</:code3:></:code2:></:code1:>