User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

tmpfs questions

Tue Oct 29, 2013 7:02 am

in my case df shows

devtmpfs 118672 0 118672 0% /dev
tmpfs 25388 (8044) 17344 32% /run
tmpfs 5120 0 5120 0% /run/lock
tmpfs 50760 0 50760 0% /run/shm

in the motion project there they made a /run/motion/ subdir for
camera output ( above usage already).
but /run is definitely used and only 25MB,
the /run/shm/ is empty and 50MB, can i use that?
( what is it for / used by ) ?

and the numbers not add up? if the tmpfs dirs are on devtmpfs,
devtmpfs - 3 subdir tmpfs: 35MB missing
or are these not related?

my first test high quality MOTION capture ( to /run/motion/ )
filled it up in 2 hours. camera stopped, RPI still running, reboot ok.
but actually i think if /run is used up, some other programs must fail?
and the /run/motion/ setup is unwise??

rayjoh
Posts: 25
Joined: Thu May 23, 2013 11:48 am

Re: tmpfs questions

Tue Oct 29, 2013 7:34 am

devtmpfs 118672 0 118672 0% /dev
A filesystem that contains information about devices. The files is pointers to device drivers in the kernel.
tmpfs 25388 (8044) 17344 32% /run
Used by daemons to save temporary information.
tmpfs 5120 0 5120 0% /run/lock
Used to prevent the same daemon to be started more than once.
tmpfs 50760 0 50760 0% /run/shm
Can be used by You to save temporary files instead of /tmp.
if the tmpfs dirs are on devtmpfs,
devtmpfs - 3 subdir tmpfs: 35MB missing
or are these not related?
No, they are like different partitions on a hard disk.

tmpfs is used to minimize wear on the SD-card. It takes a portion of RAM memory and is always cleared when the computer shuts down, so no good to save lot of data.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: tmpfs questions

Tue Oct 29, 2013 8:53 am

thanks for the help, you guys are great!
so i will use the /run/shm/ for my (temp) camera pictures.

User avatar
jojopi
Posts: 3046
Joined: Tue Oct 11, 2011 8:38 pm

Re: tmpfs questions

Tue Oct 29, 2013 9:20 am

You can adjust the sizes of the tmpfs mounts in /etc/default/tmpfs.

As long as you do not need the data to survive a reboot, tmpfs should always be more efficient than using a real filesystem. If the machine gets short of RAM it can swap, otherwise there will be no disk I/O at all.

Even if tmpfs does swap, there should be less disk I/O than you would get with ext4 because, being volatile anyway, there is no need for regular metadata updates or journaling. And swap is easier for the SD card, because it is normally written in a circular fashion, rather than the writes being repeated on the same blocks.

KenT
Posts: 758
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
Contact: Website

Re: tmpfs questions

Tue Oct 29, 2013 11:15 am

Thanks for these useful explanations. They are very timely as I am looking into some dynamic image processing in Pi Presents and was thinking of using RAM rather than SD card for the temporary images. Hopefully faster and less wear on the SD card as I am potentially updating a 1MB image every few tens of seconds 24 hours a day.

Could you confirm that on the standard Raspbian /tmp is on the SD card so it would be better for me to use /run/shm

I also found /var/tmp. It looks like this is on the SD Card but what is it meant to be used for?

TIA
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from http://pipresents.wordpress.com

rayjoh
Posts: 25
Joined: Thu May 23, 2013 11:48 am

Re: tmpfs questions

Tue Oct 29, 2013 5:28 pm

You can check with "df"

Code: Select all

[email protected]:/tmp$ df -h /tmp
Filsystem      Storlek Använt Ledigt Anv% Monterat på
/dev/root         3,6G   2,2G   1,3G  64% /
-- Raymond

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: tmpfs questions

Tue Oct 29, 2013 8:26 pm

/dev/shm is for shared memory not for user files.

If you want /tmp to be a ramdisk put this line into /etc/fstab:

Code: Select all

tmpfs           /tmp            tmpfs   defaults,noatime,nosuid   0       0

User avatar
waveform80
Posts: 303
Joined: Mon Sep 23, 2013 1:28 pm
Location: Manchester, UK

Re: tmpfs questions

Wed Oct 30, 2013 2:34 am

KenT wrote:Thanks for these useful explanations. They are very timely as I am looking into some dynamic image processing in Pi Presents and was thinking of using RAM rather than SD card for the temporary images. Hopefully faster and less wear on the SD card as I am potentially updating a 1MB image every few tens of seconds 24 hours a day.

Could you confirm that on the standard Raspbian /tmp is on the SD card so it would be better for me to use /run/shm

I also found /var/tmp. It looks like this is on the SD Card but what is it meant to be used for?

TIA
Just had a look at Pi Presents - interesting project! Given it's predominantly written in Python, and you want to capture to memory for image processing, you might want to have a look at the examples in the picamera library (a pure python library for using the Pi's camera).

Disclaimer: I'm the author of picamera, so this is a blatant plug :)


Cheers,

Dave.

Return to “Camera board”