Skip to content

How to move speed camera to an external storage device

Claude Pageau edited this page Aug 12, 2021 · 11 revisions

Introduction

Currently I use small SSD drives for my Raspberry Pi external storage eg https://www.amazon.ca/gp/product/B07GXHPR6R/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1 but a memory stick or external usb disk drive with a power supply will also work. You can also plug a normal USB-3 2.5 inch hard drive into USB but older RPI's may not have sufficient power to operate properly. Test to see if yours works OK otherwise a USB drive with external power supply will be required.

I move all of the ~/speed-camera folder to the external drive and create a soft symlink to the mount location. This allows moving the drive to another RPI and not loosing any data or configuration if the rpi system sd card fails, Also menubox UPGRADE menu pick will work correctly with no changes.

Personally I prefer to format drives as ext4 using gparted program, when drives are not likely to be moved to a microsoft windows system. This improves performance and permissions issues. Since most external drives are NTFS format, the following steps will allow mounting of the ntfs file system to a directory on your Raspberry Pi computer, although there will be posix permissions issues.

If your USB storage device is NOT NTFS formatted then see link below for details.

https://www.raspberrypi.org/documentation/computers/configuration.html#external-storage-configuration

Step 1 Mount USB drive and setup fstab

I usually mount to /home/pi/ssd-mnt but you can mount to a folder of your choice. For this example I will assume mount point is ssd-mnt

sudo apt update
sudo apt upgrade
sudo apt install ntfs-3g   # this should already be installed

plug in usb drive

Here is an example of one of my ssd drives plugged in

sudo blkid

/dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="6284-658D" TYPE="vfat" PARTUUID="254cd2b1-01 /dev/mmcblk0p2: LABEL="rootfs" UUID="3a324232-335f-4617-84c3-d4889840dc93" TYPE="ext4" PARTUUID="254cd2b1-02" /dev/mmcblk0: PTUUID="254cd2b1" PTTYPE="dos" /dev/sda1: UUID="7476C11B76C0DECC" TYPE="ntfs" PARTUUID="cc7444a5-01"

My ssd drive is located at /dev/sda1 per above. Below is an example of my /etc/fstab entry eg

cd ~
mkdir ssd-mnt
sudo nano /etc/fstab

Add similar line to below (assumes ntfs storage device).
Note You will have to use your disk uuid, mount point, Etc for your drive or just use /dev/sda1 but disk uuid is safer

UUID=7476C11B76C0DECC /home/pi/ssd-mnt ntfs-3g auto,uid=1000,exec,rw,async,noatime,nofail,x-systemd.device-timeout=1ms  0 0

press ctrl-x y to save changes and exit nano.

You can reboot or just mount manually per

sudo umount ssd-mnt   # Just in case already mounted
sudo mount ssd-mnt

Make sure you can access the ssd drive and everything works OK including permissions. If you have problems review the rpi org doc and these instructions again. If problems persist create a github issue.

Step 2 Move speed-camera folder to USB drive and setup symlink

Stop speed camera and webserver using menubox.sh or the shell scripts Move speed-camera folder to external storage device and create symbolic link per steps below Note this could take some time depending on size of media folder

cd ~
mv speed-camera /home/pi/ssd-mnt/
ls -l ssd-mnt
ln -s /home/pi/ssd-mnt/speed-camera speed-camera 
ls -l speed-camera

speed camera link should be owned by pi per eg below

lrwxrwxrwx 1 pi pi 29 Aug 12 09:37 speed-camera -> /home/pi/ssd-mnt/speed-camera

double check permissions in speed-camera

cd ~/speed-camera
ls -l

You should see all files and folders owned by pi user. If not check your fstab mount

Step 3 Verify speed-camera operation.

Test operation of speed-camera. Ensure config.py variable verbose = True

cd ~/speed-camera
./speed-cam.py

Review log entries to check operations. You can trigger motion tracking by moving your body, hand, Etc. in the camera view.

Restart speed camera and webserver using menubox.sh or the specific shell scripts.

cd ~/speed-camera
./menubox.sh

Monitor webserver images in images and/or recent folders.