If you ever had encounter error writing to a permanent mounted drive for motion running as deamon, please consider to check the following.
- Mount Point
- I could not figure it out, but motion, ran as deamon, will not write to devices mounted in /media/<$USER>/. Point your mountpoint to /mnt.
- Folder owner and permission
- change the owner of the folder where motion.conf is pointing to (target_dir)
- sudo chown motion:adm
- change the permission
- sudo chmod 0775
- File system type (not required)
- I discovered mounting removable media as EXT4 is more convinient when mounting it permanent trough /etc/fstab
Following is an example of mounting disk to your system and configure motion, almost problem free. I assume that your mounting point is /mnt/seagate
Installing
file system drivers NTFS and Fat32, if needed
sudo apt-get update
File
system
|
command
|
NTFS
|
sudo
apt-get install ntfs-3g
|
ExFAT,
FAT, FAT32
|
sudo
apt-get install exfat-fuse
|
Create the mounting folder
sudo mkdir /mnt/Seagate
sudo chown -R desireuser:desiregroup /mnt/seagate
sudo chmod 0777 /mnt/seagate
Disk (permanent mount)
Make a
backup of /etc/fstab
sudo cp /etc/fstab
/etc/fstab.bck
Get the
UUID of the disk partition, for example /dev/sda1
Optput
/dev/mmcblk0p7: LABEL="root"
UUID="b53d31e9-e8de-4074-8c6c-deafe8bb7155" TYPE="ext4"
PARTUUID="0007c09c-07"
/dev/sda1: LABEL="Mem32" UUID="401e0caf-8633-4f7f-92d7-fdfef3478b2e"
TYPE="ext4" PARTUUID="01f27d07-01"
Append
the permanent mountpoint in /etc/fstab with following code:
Ext 4 > echo "UUID=401e0caf-8633-4f7f-92d7-fdfef3478b2e /mnt/Seagate nodelalloc ext4 defaults 0 0" | sudo tee -a
/etc/fstab
NTFS > echo "UUID=401e0caf-8633-4f7f-92d7-fdfef3478b2e /mnt/Seagate ntfs-3g defaults,permissions 0 0"
| sudo tee -a /etc/fstab
Samba Shares echo “//server/share /mnt/Seagate cifs user=user 0
0" | sudo tee -a /etc/fstab
·
defaults
- default mount settings (equivalent to rw,suid,dev,exec,auto,nouser,async).
·
In
some cases, NTFS partition owner and group may be set by defining the option
uid and gid.
·
Permissions
are also defined at the time of mounting the partition with umask, dmask, and
fmask and can not be changed with commands such as chown or chmod.
· For mounting samba shares you can specify a username and password, or better a credentials file.To use a credentials you have to create the credential file with the following codes. (replace user and password with yours)
echo " username=user
password=password" | sudo tee -a /etc/samba/credentials
sudo chown root.root /etc/samba/credentials && sudo
chmod 400 /etc/samba/credentials
Then modify the /etc/fstab by replacing "user=user"
with "credentials=/etc/samba/credentials"
User could be guest or username=yourusername,password=yourpassword
Mount
the partition
sudo mount -a
Motion Setup
For best result your host machine should have a static IP for the live streaming
Make
sure that the camera is correctly detected.
You should see the name of your camera when
you run the command below. If it is NOT there, then there is some problem with
camera or the camera is not supported in motion.
lsusb
Install
Motion
sudo apt install -y
motion libio-socket-ssl-perl libnet-ssleay-perl perl
Configure
Motion
sudo
cp /etc/motion/motion.conf /etc/motion/motion.conf.bck
sudo nano /etc/motion/motion.conf
#
Daemon
daemon
off > on
#
Capture device options
Width
320 >
640 (optional)
height
to 240 > 480
(optional)
framerate
2 > 12 - 24
# Motion Detection
Settings:
post_capture
0 > 5
event_gap
60 > 15 - 60
# Image File Output
quality
75 >
100 (optional)
# Target Directories
and filenames For Images And Films
target_dir
/var/lib/motion target_dir /mnt/Seagate/motion
# Live Stream Server
Stream_quality 50 >
100 (optional)
Stream_localhost on >
off
# HTTP Based Control
Webcontrol_localhost on >
off
Exit Nano and save
settings.
Configure
Motion Daemon
sudo cp /etc/default/motion /etc/default/motion.bck
sudo nano /etc/default/motion
start_motion_daemon=no >
yes
Exit Nano and save
settings.
Start
Motion daemon
sudo
systemctl enable motion
sudo
systemctl restart motion