When the network share goes offline... #7351
-
I noticed the other week, after goofing up my NAS temporarily, that when the network share for storage gets unmounted or isn't mounted at boot, Frigate will create a directory /mnt/frigate and use up all the host storage. I've done some searching and from what I gather, the container could be prevented from booting using a script, if the mount directory is not already present. I'm a little out of my depth here as I've not tried setting up scripts in a Docker compose file before. Is there any documentation on this or a resource someone might recommend? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I had a race condition where Frigate would start before fstab would mount my SMB shares causing the host drive to fill. I switched from mounting via fstab to a systemd.mount units and changed the docker ststemd file to require the systemd mount so docker wouldn’t start until the SMB shares mounted. I also made the mount folder immutable using chattr +i command so if the share mount fails no files can be written to that folder. This will keep the host system disk from filling up with recordings. |
Beta Was this translation helpful? Give feedback.
-
Some time ago I've been messing with network shares and fstab. I always ended up spending more time than I should, while the actual fix is very easy and always work. The secret of getting it to work perfectly is:
Here is how my (relevant parts of) services:
frigate:
container_name: frigate
privileged: true
restart: unless-stopped
image: ghcr.io/blakeblackshear/frigate:stable
shm_size: "2048mb" # I guess 2G Should be more than enough
volumes:
- /dev/bus/usb:/dev/bus/usb # passes the USB Coral
- /etc/localtime:/etc/localtime:ro
- ./frigate/config.yml:/config/config.yml # my Frigate config
- ./frigate/db:/db # This must be on local storage
- frigate:/media/frigate # This is using below NFS volume
- ./frigate/labelmap.txt:/labelmap.txt # I renamed/combined some object types
- type: tmpfs # Optional: 4GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 4000000000
ports:
- "5000:5000" # WebUI
- "8554:8554" # RTSP feeds
- "8555:8555/tcp" # WebRTC over tcp
- "8555:8555/udp" # WebRTC over udp
volumes:
frigate:
driver_opts:
type: "nfs4"
o: "addr=192.168.0.123,rsize=32768,wsize=32768,hard,timeo=600,retrans=2,noresvport,nconnect=16,vers=4.1"
device: ":/volume2/frigate" |
Beta Was this translation helpful? Give feedback.
Some time ago I've been messing with network shares and fstab. I always ended up spending more time than I should, while the actual fix is very easy and always work.
The secret of getting it to work perfectly is:
Here is how my (relevant parts of)
docker-compose.yml
look like: