[SOLVED] Mount USB drive in Hassio to be used on the Media Folder with udev customization

I use multiple udev rules.

  • the original gist for USB drives

  • An extra rule for non USB drives(data/NVME) with the label as ‘STORAGE’

1 Like

I am not very strong in this, so just to clarify. You formatted the extra drive, and gave the partition the name “STORAGE”.
So you physically removed the drive from the host, and did this?

I have actually called min HAHDD01, so i’m guessing i can use HAHDD01 instead of STORAGE. But i looks like you are now skipping mounting usb drives?

You can do it via ssh on the host using packages that exist, no need to remove the drive.

lsblk, fdisk, mkfs, and e2label

@PeteDenmark I use two separate udev rules files 80- for USB drives(the original gist here) and another rule 81- in the gist I posted above.

Hello,


After formatting my external SSD drive as Fat32 I followed the steps mentioned and I can see it in the local media file. Now a question; How long after Frigate records should arrive in this file?

You’ll need to

  • stop frigate

  • move the database to /media out of /media/frigate

  • delete or temporarily remove the contents of /media/frigate

  • change the label of your drive to ‘frigate’ this will mount your drive as /media/frigate

  • if you didn’t delete the contents of /media/frigate and moved them out of the way, move them back to the newly mounted /media/frigate

  • edit the frigate.yaml and update it so it can find the database at /media/frigate.db this way the add on can find the database no matter if the drive is plugged in or not and you don’t end up with two databases.

Start frigate.
Validate frigate is writing videos to /media/frigate
In terminal df -h and find the drive(/dev/sd*1) mounted to /media/frigate, you should see the usage growing.

You cannot change the storage location of the frigate add on, so it must be in /media/frigate. But you can change the location of the database. Follow the steps above and it will start storing video on your mounted drive.

@effective

Thank you very much for this valuable information. I’ll try when I’m home tonight :+1:

I am getting these errors in frigate logs. How can I fix? I would be grateful if you help :pray:

[2023-03-16 00:56:12] frigate.record WARNING : Unable to find file from recordings database: /media/frigate/recordings/2023-03/15/20/salon/55.53.mp4
Exception in thread event_processor:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 3177, in execute_sql
cursor.execute(sql, params or ())
sqlite3.OperationalError: disk I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/lib/python3.9/threading.py”, line 954, in _bootstrap_inner
self.run()
File “/opt/frigate/frigate/events.py”, line 116, in run
Event.update(
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 1918, in inner
return method(self, database, *args, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 1989, in execute
return self._execute(database)
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 2497, in _execute
return self.handle_result(database, cursor)
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 2508, in handle_result
return database.rows_affected(cursor)
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 3269, in rows_affected
return cursor.rowcount
File “/usr/local/lib/python3.9/dist-packages/playhouse/sqliteq.py”, line 94, in rowcount
self._wait()
File “/usr/local/lib/python3.9/dist-packages/playhouse/sqliteq.py”, line 63, in _wait
raise self._exc
File “/usr/local/lib/python3.9/dist-packages/playhouse/sqliteq.py”, line 178, in execute
cursor = self.database._execute(obj.sql, obj.params, obj.commit)
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 3184, in execute_sql
self.commit()
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 2950, in exit
reraise(new_type, new_type(exc_value, *exc_args), traceback)
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 191, in reraise
raise value.with_traceback(tb)
File “/usr/local/lib/python3.9/dist-packages/peewee.py”, line 3177, in execute_sql
cursor.execute(sql, params or ())
peewee.OperationalError: disk I/O error
[2023-03-16 00:56:35] frigate.http ERROR : Exception on /stats [GET]
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 2073, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1519, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1517, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1503, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File “/opt/frigate/frigate/http.py”, line 605, in stats
stats = stats_snapshot(current_app.stats_tracking)
File “/opt/frigate/frigate/stats.py”, line 125, in stats_snapshot
storage_stats = shutil.disk_usage(path)
File “/usr/lib/python3.9/shutil.py”, line 1262, in disk_usage
st = os.statvfs(path)
FileNotFoundError: [Errno 2] No such file or directory: ‘/media/frigate/recordings’
[2023-03-16 00:56:37] frigate.record ERROR : Error occurred when attempting to maintain recording cache
[2023-03-16 00:56:37] frigate.record ERROR : [Errno 5] Input/output error: ‘/media/frigate/recordings’

Did you delete your old recordings or move them?

If you moved them to the new drive it’s likely a permission issue. If you deleted them, it’s just the pruning of old recordings it can’t find and is normal

If you want to get rid of the errors quickly (if you deleted your old recordings) temporarily set your frigate.yaml to retain for 5 minutes. Let frigate clean itself. Then restart frigate with your old retain recording setting. @effective

Sorry, I don’t understand how to do this. Can you show an example? :relaxed:

“ temporarily set your frigate.yaml to retain for 5 minutes”

1 Like

Sure, In your frigate.yaml at the top, you can add the ‘record’ section, which is the global config. You would comment out days, and uncomment hours or minutes, and set a number.

database:
  path: /media/frigate.db

record:
  enabled: True
  retain:
    days: 10
    # hours:
    # minutes: 
    mode: all
  events:
    retain:
      default: 10
      mode: active_objects
      objects:
        dog: 10
        person: 10
        car: 10
    pre_capture: 5
    post_capture: 60

Thank you very much. I followed the steps you showed. Everything is working right now. I’ll follow up for a while and give feedback.

1 Like

I’ve tried to get an ssd in an external enclosure mounted. I can see a folder with the same name as my drive, but there isn’t anything in it when I open it in the webUI or externally through sambashare. on an ODROID N2+, I’m running:
Home Assistant 2023.3.5
Supervisor 2023.03.1
Operating System 9.5
Frontend 20230309.1 - latest

What am I doing wrong? Please let me know whatever other information I can provide

records are not visible. After restarting HA, the logs appear but disappear again after a while. I have to restart Home Assistant when this problem happens.


I’ve shown you what I know.

As you can see, my previous posts. This is exactly what I have done running frigate

  • udev rules for USB
  • drive labeled ‘frigate’
  • mounted to /media/frigate, recordings and clips should be at /media/frigate/recordings and clips at /media/frigate/clips
  • database set in frigate.yaml to /media/frigate.db, /media is part of the HAOS drive so even if the ‘frigate’’ drive is unplugged the database is still available.

I can’t tell if you have permission issues since you are using fat32. Or driver issues(fat32 and NTFS need extra drivers installed I think)

All my drives are ext4 native to Linux.

I understand you, very well. The usb created for the udev rule was formatted as fat32 on the windows computer. The external SSD to be used for the frigate records was formatted as ext4. I definitely think I made a small mistake somewhere, but I haven’t been able to identify where I made a mistake yet. I will continue researching. Many thanks for your interest and patience.

1 Like

I’m asking for be sure :wink:
In the last case, which should be the database path in the frigate.yml file?
database:
path: /media/firgate/frigate.db
or
database:
path: /media/frigate.db

1 Like

/media/frigate.db

:wink:

thank you very much :+1: :slightly_smiling_face:

1 Like

@Deckoz2302 After some fiddling I was able to boot external storage with a fat32 formatted usb stick. Thank you very much for all the information you have provided :wink: :+1:

1 Like

Estoy terminado el dia, sin llegar a montar un pinche USB de 4 TB con particiones ntfs a mi Raspberry Pi 4 con un hub USB de por medio (HA en todo el Hardware lo reconoce)
Aplico el comando mount y me denega preguntandome si soy root
Aplico whoami…y me sale
root…(claro que soy root)
XQ tan dificil
Otra cosa…aplico el comado lsblk y no me sale nada (no entiendo??? es un comando simple de linux?
He leido los comentarios y me hablan de scripts, yaml, copiar un chorizo de comandos, etc , etc y no entiendo xq lo tengo q hacer mas dificil si Linux entrando como root lo hago en una patada.
El complemento de Samba no me funciono, instale el de SambaNAS pero me pide otro chorizo de acciones.
Si alguien del Foro encuentra la posta…sin tanto…recibira mis felicitaciones
(Aclaro, Home Assistant es un excelente SO basado en linux, lo q no entiendo xq se complico en esto q tendria q ser tan simple como en Linux)