Auto-create ramdisk when Raspberry Pi or Linux start up

In my previous project, I developed a real-time system, so faster speed for read/write temporary data is necessary. After setting, when Raspberry Pi starts up, a small ramdisk will auto-create.

What is Ram Disk?
A RAM disk is a portion of RAM which is being used as if it were a disk drive. RAM disks have fixed sizes, and act like regular disk partitions. Access time is much faster for a RAM disk than for a real, physical disk. However, any data stored on a RAM disk is lost when the system is shut down or powered off. RAM disks can be a great place to store temporary data.(online material)

Actually, it’s very easy to set up ram disk, I list the steps.
I want to mount the smallest ramdisk in /mnt/rd.
1. Create a folder
It means that you want to create a ramdisk here. Go to Terminal and type following command

$ sudo mkdir /mnt/rd

2. Edit /etc/rc.local file
I use nano as editor

$ sudo nano /etc/rc.local

Copy all in the red box to the file before “exit 0” (ignore other lines)
3. Reboot Pi and check ramdisk
After reboot your pi, you type “df -h” to check disk status, you will see ram0, size is 7.8mb.
Yes, you can use it to boost your project.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s