I'm using a bash script on my Raspberry Pi B+ to take photos with the RaspiCam all 60 seconds and upload them to my FTP server:

STARTDATE=$(date +"%Y-%m-%d_%H_%M_%S")
echo "Camerascript started at $STARTDATE" > /home/pi/fb/$STARTDATE.txt
echo -e "Interval set to $DELAY\n" >> /home/pi/fb/$STARTDATE.txt
while [ 1 ]; do
 DATE=$(date +"%Y-%m-%d_%H_%M_%S")
 echo "Taking picture $DATE.jpg..." >> /home/pi/fb/$STARTDATE.txt
 raspistill -q 10 -th none -o /home/pi/fb/$DATE.jpg >> /home/pi/fb/$STARTDATE.txt 2>&1
 echo "Picture $DATE.jpg taken" >> /home/pi/fb/$STARTDATE.txt
 curl -T /home/pi/fb/$DATE.jpg  ftp://myftpserver --user myuser:mypass >> /home/pi/fb/$STARTDATE.txt 2>&1
 echo "Picture $DATE.jpg uploaded" >> /home/pi/fb/$STARTDATE.txt
 echo -e "Waiting $DELAY sec...\n" >> /home/pi/fb/$STARTDATE.txt
 sleep $DELAY

This works for 3 hours and some minutes. After that, raspistill quits work. This are the corresponding entries from my log file:

Taking picture 2016-02-03_13_40_14.jpg...
mmal: Could not rename temp file to: /home/pi/fb/2016-02-03_13_40_14.jpg; No space left on device
Picture 2016-02-03_13_40_14.jpg taken
curl: Can't open '/home/pi/fb/2016-02-03_13_40_14.jpg'!
curl: try 'curl --help' or 'curl --manual' for more information
Picture 2016-02-03_13_40_14.jpg uploaded
Waiting 60 sec...

Taking picture 2016-02-03_13_41_20.jpg...
mmal: main: Error opening output file: /home/pi/fb/2016-02-03_13_41_20.jpg~
No output file will be generated

There is plenty of space left on the device /home/pi/fb/ so I don't understand why raspistill complains about that. I also don't get why raspistill is trying to save the following photos with a ~ behind the file extension.


This is the output of df:

Filesystem                                   1K-blocks    Used Available Use% Mounted on
/dev/root                                     30137128 3726572  25130092  13% /
devtmpfs                                        185764       0    185764   0% /dev
tmpfs                                           190036       0    190036   0% /dev/shm
tmpfs                                           190036    4580    185456   3% /run
tmpfs                                             5120       4      5116   1% /run/lock
tmpfs                                           190036       0    190036   0% /sys/fs/cgroup
//   1422048   65980   1356068   5% /home/pi/fb
/dev/mmcblk0p1                                   61384   20296     41088  34% /boot
tmpfs                                            38008       0     38008   0% /run/user/1000

As I mentioned earlier, there is plenty of space left. But the error seems to be related to the fact that /home/pi/fb is a network share. When I change the folder to a local one on my SD card the process runs for hours without complaining. Interesting is: When I restart the script it is even not able to write the "Camerascript started at..." to my log file (but it was able to write all the error messages to log for hours after raspistill stopped working...), instead echo complains that there is "No space left on device". BUT I'm able to copy huge files to the /home/pi/fb share without any issues.

So I guess I have to change my question to: Why is every command in my bash script complaining about to little space while every command I use outside of the script is not?

  • I seem to remember something about having to make unused space on your SD card available to the OS as a separate take when the card gets formated. Fo you remember doing so when you prepared the card? Also, just for fun, did you try a bigger card just to see if that solved the problem? Feb 3, 2016 at 23:45
  • John Holmes is absolutely right: the ext4 format (standard on Raspbian) defaults to reserving 5% of available space for root's use only (for a variety of reasons); if raspistill is complaining it's out of space that's because that's what the filesystem is telling it.
    – Dave Jones
    Feb 4, 2016 at 10:43
  • Actually that 5% space reservation is common at least to ext2 and ext3 file-systems as well - you can tweak it with tune2fs -r but you really should read up in the manpage first...!
    – SlySven
    Feb 5, 2016 at 15:17

1 Answer 1


Take a look over on the Foundation's site here...

Seems to be exactly the problem you have. Running the raspi-config provides access to fixing the size problem.

Run raspi-config and select the expand_rootfs option. Reboot. This should fix your problem.

  • Welcome to Stack Exchange and the Raspberry Pi flavoured corner of it! I have edited your contribution (provided it gets accpeted) to hide the URL of the link.
    – SlySven
    Feb 4, 2016 at 23:25
  • Thanks for you input. I updated my question to clear things up, not all "running out of space" issues are related to a not expanded root file system. Running the "expand_rootfs" is one of the first things I do after setting up one of my Raspis ;-)
    – Simon
    Feb 5, 2016 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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