dciancu / unifi-protect-unvr-docker-arm64

UniFi Protect UNVR Docker container for arm64
https://hub.docker.com/r/dciancu/unifi-protect-unvr-docker-arm64
37 stars 1 forks source link

Unifi Protect can't capture the available storage #9

Open gnbon opened 3 months ago

gnbon commented 3 months ago

I appreciate the great work on this project. While setting it up, I encountered an issue where my storage was not recognized at all. I'm currently troubleshooting this problem. I of course changed the hostname and added boot commands as well. Either if I have the wrong settings or there are any known issues related to this, please let me know.

Environments

df -h output

docker-compose.yml

services:
  unifi-protect:
    image: dciancu/unifi-protect-unvr-docker-arm64:stable
    tty: true
    hostname: UNVR
    extra_hosts:
      - "UNVR:127.0.1.1"
    container_name: unifi-protect
    stop_grace_period: 2m
    cgroup: host
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup
      - /mnt/storage/srv:/srv
      - /mnt/storage/data:/data
      - /mnt/storage/persistent:/persistent
    environment:
      - container=docker
      - STORAGE_DISK=/dev/sda1
      - TZ=UTC
    restart: unless-stopped
    cap_add:
      - dac_read_search
      - sys_admin
    security_opt:
      - apparmor=unconfined
      - seccomp=unconfined
    tmpfs:
      - /run
      - /run/lock
      - /tmp
      - /var/run
      - /var/run/lock
    privileged: true
    network_mode: host

I've also attached two screenshots showing additional information. Please let me know if you need any further details or clarification on this issue. image image

AnthonyOGorman commented 3 months ago

Any update on this, I am having the same issue.

RobBie1221 commented 2 months ago

I spent quite some time looking into this.

So far, I have the following findings with this image: stable - Unifi is unable to capture storage edge - Unifi is unable to capture storage Once you connect to a doorbell it partially works. Somehow it is recording, but Protect doesn't see it is recording. The app somehow can playback video, but from a web browser it doesn't work. Big disadvantage, you can't configure e.g. smart detection zones because the web browser want's you to connect a storage. I also have problems with a smart chime continuously rebooting or reconnecting (which may or may not be related to this, anyhow the chime worked perfectly on the previous image I used from markdegroot).

What I tried, because people describe this image is actually working, to use the following tag: UNVR4.al324.v3.2.12.7765dbb.240126.0152

The key difference is that this image runs Unifi OS v3 instead of v4. This is actually working. It comes with an old protect app, but once running you can update Protect to v4.1.53 (which works as long as you don't remove the container and re-create it).

I tried, with a working config, to update the container to the latest again, but this breaks the storage. I checked the error logs, maybe this gives a hint: 2024-09-13T20:01:27.307Z - error: [unvrFlashStorageMigration] Failed to check rwfs migration info via ustorage: Unexpected end of JSON input SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at WD (file:///usr/share/unifi-core/app/service.js:197:56072) at Kye (file:///usr/share/unifi-core/app/service.js:197:57153)

This whole exercise does make me wonder. I use a Raspberry Pi 4 with a clean install of Debian Bookworm, following all instructions on the main page using exactly the compose file in this repo (adjusting STORAGE_DISK). @dciancu Did you actually test the image with Unifi OS v4? Or is there someone who can confirm this is actually working with above setup? It makes a whole lot of difference if I try to fix something that does not work on my setup instead of fixing something that is not working at all :)

RobBie1221 commented 2 months ago

One thing to add, looking at the dockerfile used to make this container, it seems to always use debian 11, both for containers running Unifi OS v3 and v4. Just a random thought I had, would it be possible the infrastructure of Unifi OS v4 is created around debian 12?

Howaner commented 2 days ago

I had the same problem with the newer versions and tried to fix it today.
I could fix it by changing two things.

  1. docker exec into your unifi protect docker container
  2. Edit /usr/bin/ustorage and replace the two lines beginning with sbytes= and sused= to the following lines:
    sbytes=$(df -B1 --output=size -k /srv | awk 'NR==2 {print $1}')
    sbytes=$(( sbytes * 1024 ))
    sused=$(df -B1 --output=used -k /srv | awk 'NR==2 {print $1}')
    sused=$(( sused * 1024 ))
  3. Open /usr/share/unifi-core/app/service.js and replace all useGrpc:!0 with useGrpc:!!0
  4. Restart docker container

I'm planning to create a merge request for it.

PeterSchmidt23 commented 15 hours ago

I had the same problem with the newer versions and tried to fix it today. I could fix it by changing two things.

  1. docker exec into your unifi protect docker container
  2. Edit /usr/bin/ustorage and replace the two lines beginning with sbytes= and sused= to the following lines:
sbytes=$(df -B1 --output=size -k /srv | awk 'NR==2 {print $1}')
sbytes=$(( sbytes * 1024 ))
sused=$(df -B1 --output=used -k /srv | awk 'NR==2 {print $1}')
sused=$(( sused * 1024 ))
  1. Open /usr/share/unifi-core/app/service.js and replace all useGrpc:!0 with useGrpc:!!0
  2. Restart docker container

I'm planning to create a merge request for it.

Good Job! I can confirm, that this is working.