Raspberry Pi - Stalled Camera Process and Out of Disk Space

Procrastination fail! The day before yesterday my raspberry pi finally ran out of disk space in the middle of taking the day’s time lapse photos. I never got around to automating the transfer of raw files off of the pi itself. Here’s how I got it working again.

Check Disk Space

To confirm the hard disk was actually full:

$ df -H
Filesystem Size Used Avail Use% Mounted on
/dev/root 63G 60G 0 100% /
devtmpfs 190M 0 190M 0% /dev
tmpfs 194M 0 194M 0% /dev/shm
tmpfs 194M 20M 174M 11% /run
tmpfs 5.3M 4.1k 5.3M 1% /run/lock
...

/dev/root is the main file system to pay attention to, and it’s clearly 100% full.

Remove Files

For an immediate quick fix I did this manually to start. I went back to my old notes and used the scp command to copy files to my laptop. Then I manually uploaded them to AWS S3 buckets, confirmed the transfer, and then deleted the files off of the pi.

With a lot of files, this was a long process, and I still need to set it up to move the files from the pi to AWS without needing my laptop in the middle.

Test Camera

With more space available, I tested the camera to make sure it would be ready to go for the next day’s photo taking:

$ raspistill -o Desktop/image.jpg
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component could not be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

Yikes, problem!

Some googling hinted that this error may come up if another process is using raspistill in the background.

Another hint: in the latest folder of time lapse photos, there was an empty file container (file name was along the lines of timelapse-2020-03-11-0090.jpg~) which must have been created just as the disk ran out of space. I deleted this non-file, but it indicated that the script may still be running in the background if it was interrupted like this.

I tried resetting the camera unit via sudo raspi-config but this did not make it work.

This Q&A suggested some other troubleshooting methods, but updating the firmware or reinstalling Raspbian from scratch seemed like overkill.

It did give one hint though, a command to see what raspistill was doing in the background:

$ sudo ps aux|grep raspi
pi 21373 0.0 0.0 63416 0 ? Sl Mar11 0:05 raspistill -o /home/pi/Desktop/timelapses/2020-03-11/2020-03-11_1920x1440_q85_awb-horizon-%04d.jpg -v -n -t 36900000 -tl 187500 -w 1920 -h 1440 -awb horizon
pi 28710 1.0 0.5 7332 1924 pts/0 S+ 01:12 0:00 grep --color=auto raspi

The second process was referenced in the Q&A as the normal output. This first process though (21373) is clearly my time lapse command…one which should have ended at the end of the day on the 11th, but was clearly still hung up!

So I killed the process:

$ sudo kill 21373

And tested the camera again:

$ raspistill -o Desktop/image.jpg
$ cd Desktop/ && ls
image.jpg scripts timelapses

SUCCESS!