Up until May 2021, motion was working successfully on my Raspberry Pi 4. After May 2021, when motion is running and my web camera is enabled, as soon as it detects any motion, the camera disables itself.
I've reviewed the following related questions before posting, but they did not offer any solution:
What permissions does Motion require to write to specific directory?
Motion ffmpeg_open: url_fopen - error opening file (check access rights to target directory)
I checked /var/log/motion/motion.log
and it reports the following:
[1:ml1] [ERR] [ALL] [Nov 23 11:05:46] myfopen: Error opening file /media/samba_disk/motion/01-20211123110546-snapshot.jpg with mode w: Permission denied
[1:ml1] [ERR] [ALL] [Nov 23 11:05:46] put_picture: Can't write picture to file /media/samba_disk/motion/01-20211123110546-snapshot.jpg - check access rights to target directory
Thread is going to finish due to this fatal error: Permission denied
[1:ml1] [ERR] [EVT] [Nov 23 11:05:46] event_image_snapshot: Could not create symbolic link [01-20211123110546-snapshot.jpg]: Permission denied
[1:ml1] [NTC] [ALL] [Nov 23 11:05:46] motion_loop: Thread exiting
[1:ml1] [NTC] [STR] [Nov 23 11:05:46] stream_stop: Closing motion-stream listen socket & active motion-stream sockets
[1:ml1] [NTC] [STR] [Nov 23 11:05:46] stream_stop: Closed motion-stream listen socket & active motion-stream sockets
[1:ml1] [NTC] [VID] [Nov 23 11:05:46] vid_close: Cleaning up V4L2 device
[1:ml1] [NTC] [VID] [Nov 23 11:05:46] v4l2_cleanup: Closing video device /dev/video0
To confirm, the target directory in /etc/motion/motion.conf
:
more /etc/motion/motion.conf | grep target_dir
target_dir /media/samba_disk/motion
Checking the permissions of the target directory, the owner and group is motion
and permissions are 777
:
ls -la /media/samba_disk/
drwxrwxrwx 51 motion motion 12288 Nov 14 14:58 motion
My local user is also a member of the motion
group:
$ groups
tv adm dialout cdrom sudo audio video plugdev users input netdev debian-transmission motion gpio i2c spi
I also made sure that the disk of the target directory is mounted and has free space:
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 916G 340G 531G 40% /media/samba_disk
Everything appears to be set correctly for files to be written to motion's target directory. So why do I still receive write permission errors?
ps aux | grep -v grep | grep motion
? – Seamus Dec 08 '21 at 16:54psaux
command returnsmotion 765 0.5 0.2 178200 19604 ? Sl 07:24 0:18 /usr/bin/motion
– jimjamz Dec 21 '21 at 08:28