Someone? Please?
Hello all.
I am sooo weak in writing udev rules, so i’m having the hardest time.
I have two internal discs on my Intel NUCi5. An m.2 nvme and a SSD. Problem is that the system drive is on sdb, and the extra drive is on sda, so i want the rule to skip mounting the sdb drive.
I have tried different udev rules, but it gives me weird results.
This is the original rule:
# Filter on block devices, exit otherwise
# CAUTION: Change to 'sd[b-z][0-9]' if booting from a USB drive (e.g.: sda)
KERNEL!="sd[a-z][0-9]", GOTO="abort_rule"
# Skip none USB devices (e.g.: internal SATA drive)
ENV{ID_PATH}!="*-usb-*", GOTO="abort_rule"
I have modified it to:
# Filter on block devices, exit otherwise
# CAUTION: Change to 'sd[b-z][0-9]' if booting from a USB drive (e.g.: sda)
KERNEL!="sd[a-z][0-9]", KERNEL=="sdb[0-9]" GOTO="abort_rule"
# AND DELETED THIS RULE
ENV{ID_PATH}!="*-usb-*", GOTO="abort_rule"
I have also tried
# Filter on block devices, exit otherwise
# CAUTION: Change to 'sd[b-z][0-9]' if booting from a USB drive (e.g.: sda)
KERNEL!="sd[c-z][0-9]", GOTO="abort_rule"
KERNEL!="sd[a][0-9]", GOTO="abort_rule"
and
KERNEL!="sd[a,c-z][0-9]", GOTO="abort_rule"
Got the weirdest result, where lsblk showed that the USB drive on sdc wasn’t mounted, but it actually was and was accessible in the media folder. The sda drive did show up as mounted, but wasn’t accessible from the media file.
One time, when i did a host restart, it actually mounted every drive, including the ram, so had to do a complete system restore.
So please - how do i make the udev rule, so that i mounts every sd drive, including sata, except the sdb.
How did you get the USB with the key imported into HA ? I don’t see this option anymore in the latest release
I used this solution and its working. But cant get automatic drive mount. Fighting with that right now
Great, thanks. Just wonder how you have created the required SSH Key ?
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’
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.
Thank you very much for this valuable information. I’ll try when I’m home tonight
I am getting these errors in frigate logs. How can I fix? I would be grateful if you help
[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?
“ temporarily set your frigate.yaml to retain for 5 minutes”
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.
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.