Ubuntu – data stored in RAM filesystem – TMPFS

In my Cubieboard2 I use Lubuntu. Since I have connected barometer and arduino to my cubieboard, I read data from that devices and store it to cubieboard2 filesystem. Since NAND memory is not quite suitable for such frequent changes because of wear-out of the memory cells over time, I’ve created temp space in RAM memory. Cubieboard2 has 1GB DDR memory so there is some space for it.


I will use TMPFS and not older RAM disks – ramfs. Tmpfs is supported by the Linux kernel from version 2.4 and up. On reboot, everything in tmpfs will be lost. The memory used by tmpfs grows and shrinks to accommodate the files it contains and can be swapped out to swap space.
To get more comprehensive info regarding those filesystems read this post or this post.

To get info of total and available memory in MB type:

free -m

Lubuntu image for Cubieboard doesn’t contain dedicated swap. You can check it by gparted or simply by:

swapon -s

I have 581MB free from total 811MB so it’s safe allocate some space for diskmem.
Since my files are small and replacing it’s data I will allocate max 10MB for file system in memory.

mkdir -p /home/linaro/projects/memdisk
sudo chown linaro:linaro /home/linaro/projects/memdisk
sudo mount -t tmpfs -o size=10M,mode=0755 tmpfs /home/linaro/projects/memdisk

My user and group name is linaro, so I changed ownership to that user/group.

To make mount permanent also after reboot, I have added a line in /etx/fstab:

sudo mcedit /etc/fstab
tmpfs /home/linaro/projects/memdisk tmpfs size=10M,mode=0755,uid=linaro,gid=linaro 0 0

 

I hope I will prolong the lifetime of my NAND memory on Cubieboard2 by adding this filesystem in RAM. To test the total capacity of the folder I have created a 10MB file (0.5+0.5+9MB) and then tried to add a file with 1 byte. It worked – no space left on device as you can see on the screen capture below.

To create a 10MB file type:

dd if=/dev/zero of=9mb-file.bin bs=1024k count=10

If you use tmps for apache2 /var/log then follow this: initd-script-to-create-essential-dirs-apache


Related Posts

Cubieboard2 – Lubundu – Extending NAND from 2GB to 4GB

When I install new Lubuntu NAND image to my new Cubieboard2 I had only 2GB of space out of 4GB available. I followed this forum to expand the filesystem to 4GB. sudo nand-part In my[…]

Continue reading ...

Cubieboard and 2.00mm vs 2.54mm pins

Cubieboard has thickness 2.00mm 2×20-pin-header that is not so suitable for home hobbiest. Arduino and other small boards uses 2.54mm pin (0.100inch) To connect it I have bought 2.00mm to 2.54mm 40pcs Wire Cable 2P[…]

Continue reading ...

Enable UART on Cubieboard with Lubuntu

I wanted to connect my cubieboard with lubuntu to my arduino via serial communication. For that I had to enable a UART and connect pins to my arduino (only RX/TX is needed). I have arduino[…]

Continue reading ...