I am about to set up an outdoor timelapse with rpi and I wont have internet connection nor display on the site. What is a good way to prevent rpi clogging up with images? I am thinking maybe some script (can you point in the right direction?) that would make the rpi move images from directory on the rpi to a connected flashdisk upon the disk insertion. Any advices?

| improve this question | | | | |
  • You could easily set the save location for the pictures as a USB storage device connected to the Pi. That way the images are never stored on the SD card at all. – Darth Vader Jan 8 '17 at 16:13
  • Yeah, expanding the memory with usb disks is a good idea, but still what if I run outa memory on them. – wesalius Jan 8 '17 at 19:23
  • Lets assume you are capturing jpeg images, if you connect something like a 2TB hard drive to the Pi, you are going to have trouble filling it. You need to explain why a large external drive isn't going to work in your use case. – Darth Vader Jan 8 '17 at 20:53
  • Thank you for pointing that out. Large external harddrive will be the easiest solution I guess. I will go for it. – wesalius Jan 14 '17 at 10:27

A large hard drive connected to the Pi will probably be the easiest solution. There are plenty of scripts out there that will do time-lapses. It depends if you are using the Pi Camera or a USB webcam, a quick search on the internet will find a suitable piece of code.

As a quick example is a piece of Python code that takes 10 images using the Pi Camera:

from picamera import PiCamera

camera = PiCamera()

for i in range(10):

It also numbers the images in numerical order so the images are outputted in the order they were taken. If you are interested this tutorial here is easy to follow: https://www.raspberrypi.org/learning/timelapse-setup/worksheet/

The important bit is to set the save location of your pictures as the external hard drive connected to the Pi.

| improve this answer | | | | |
  • I have no problem with taking the timelapse pics, so only the first sentence of your answer is on the point actually... – wesalius Jan 15 '17 at 12:13
  • Your question, unless I am mistaken, suggests you were looking for ideas on how to prevent the SD card from being filled with images. You haven't specified in your question that the time-lapse part was causing you problems. However, as mentioned in my answer there are more than enough tutorials out there on the topic, I just included an example to give you an idea of what is possible. Furthermore, in a comment on your question you wrote that a large external hard drive was the solution you were after. So how have I not answered your question? – Darth Vader Jan 15 '17 at 13:10
  • To a question "How to easily “unload” images from timelapse rpi without display onto flashdisk" you answer with 2 relevant sentences (the 1st and the last one), and a ton of not-asked-for advice. No disrespect here, only stating that majority of your answer was not an answer to the original question. – wesalius Jan 17 '17 at 23:01
  • Ok, I think we have misunderstood each other a little. As a starting point, what camera are you using with the Pi? Have you got a time-lapse script already? What operating system are you running? – Darth Vader Jan 24 '17 at 14:21
  • I have the original v2 camera module, I have a time lapse script ready and I am running raspbian. – wesalius Jan 28 '17 at 8:58

I'd suggest using some custom udev rules to trigger copying images/video files from the SD to a connected USB drive when it's attached. Examples of similar udev rules are discussed here, here and here.

The basics are to create a rule using the RUN+= directive to run a script that will mount the drive; copy the files and finally unmount the drive. You could also have the rule create an extra symlink for the drive in /dev/ so your script can find it at the same location regardless of the underlying device name, this would be with the SYMLINK+= directive, although you can also pass the kernel selected name to your script as a command line option. The rules can be triggered to match on a host of identifiers for the USB disk you've chosen but I'd be cautious about being too restrictive in case you ever need to change to another device in the future and have to re-write the rule -- it'd be neat if you could get the rule to trigger on the partition label (really simple to set on a new drive if you need to) but I'm not sure that's supported out-of-the-box.

Some problems that you may run into are:

  • Stopping some other process from auto-mounting the drive before, during an after your script has run
  • You may need to fork your script into the background whilst copying a lot of data to prevent udev from blocking or killing your script with a timeout.
  • Debugging your script might be tricky when being run by udev as it will be run "blind" with a limited environment and possibly permissions

You may want to consider also adding some extra LEDs to your Pi so your script can give your some visual feedback on the script progress such as "working" and "safe to remove", but that's up to you.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.