Wednesday, January 30, 2013

Moving Raspberry Pi logs and temp files to RAM

This link explains how to move your temporary files from secondary storage device (HDD, SDCard, SSD, etc.) to RAM in general--seems to be the link no longer working. I did a similar thing with my Raspberry Pi because the temporary files are not of interest in my particular setup. The difference lays in the details because of limited RAM space in Raspberry Pi, I decided to limit the amount of RAM for the temporary files to 5MB at most. This is how my Raspberry Pi /etc/fstab looks like (the snippet below only shows relevant lines for the temporary files setup):
tmpfs    /tmp        tmpfs      defaults,noatime,mode=1777,size=5m    0    0
tmpfs    /var/log    tmpfs      defaults,noatime,mode=1777,size=5m    0    0
tmpfs    /var/tmp    tmpfs      defaults,noatime,mode=1777,size=1m    0    0
The  "size=5m" and similar parameters force the RAM size used for the corresponding temporary file to certain megabytes. The "m" suffix corresponds to "mega bytes". The details are explained in this link.

I have tested my Raspberry Pi with several reboots and cold start and everything works without a hitch.

I need to increase the amount of RAM dedicated to /tmp to 5MB after zeromq and nanomsg build (compilation) failure happened when /tmp was still 1 MB. This is due to gcc places the intermediate compilation result (i.e. the expanded asm code + macros) in /tmp before linking takes place. It seems some of the code expands to > 1MB of size. After changing /tmp to use 5MB of RAM, everything worked without a hitch.
Post a Comment

No comments: