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

hi,
Could you point me in the right direction, please? I’m trying to use rule 81 to map secondary internal hdd to save frigate recordings. I can manually map the drive using “mount /dev/sda /mnt/data/supervisor/media/frigate” from terminal after reboot. Script is saved in the right folder for udev rules but upon reboot, nothing happens. I’ve change all the “STORAGE” entries to “frigate”. Should I unplug the flash drive at this point? Any way to figure out why it’s not mapping the drive?
Thank you for all your suggestions :slight_smile:

This procedure works for me on a x86 bare metal installation booting on internal SSD drive. I have used the original version of 80-mount-usb-to-media-by-label.rules Looks like the problem that is why it didn’t work the first time is the usb drive. There is a video further down that you need to try different usb drive if it doesn’t work for the CONFIG.

I just spent way too long trying to do exactly that so here’s what works:

Remove the system HDD from your HA computer and attach it to a different linux pc (or live disc)
create 2 temp folders wherever you want. sdb3 and sdb5
(I’m going to use /mnt as an example and assume your HassOS drive is sdb in the 2nd pc)

create 80-mount-sdb.rules and put this inside and then copy it to BOTH temp folders:

KERNEL!="sd[a-z][0-9]", GOTO="abort_rule"

ACTION=="add", RUN{program}+="/usr/bin/systemd-mount --no-block --automount=no --collect /dev/disk/by-uuid/<<YOUR PARTITION UUID>> /mnt/data/supervisor/media/frigate"
ACTION=="remove", RUN{program}+="/usr/bin/systemd-umount /mnt/data/supervisor/media/frigate"

LABEL="abort_rule"`
temp folder 1: (/mnt/sdb3)
sudo unsquashfs -i /dev/sdb3      #decompress the compressed filesystem
sudo cp 80-mount-sdb.rules squashfs-root/lib/udev/rules.d      #copy your file to the correct folder
sudo mksquashfs squashfs-root/ squash.rootfs.1      #compress the filesystem
sudo dd if=./squash.rootfs.1 of=/dev/sdb3      #replace the old filesystem with the new one

temp folder 2 is the exact same commands but replace sdb3 with sdb5.

These instructions worked well for me but only after I used a different computer to format the external drives as ext4 volumes. HA OS unfortunately does not include CLI or UI tools to format USB disks with linux filesystems.

1 Like

Correction for #3: “Import from USB” has been removed from the UI ( I think since Version 2023). You will need to use the cli for it now. Plug in the USB “CONFIG” drive, open a ssh (or use “Terminal” in HA) and run the following command:
**ha os import** (without quotes).
Continue with #4.

I’m on 2023.8.2 and the option in the UI is still there

I’ve successfully made this work - but now I’m confused as to how I might allow various addons to have access. Calibre and qBittorrent are the first two I’ve tried but I don’t understand how the root file system relates to whats available in the docker containers.


Its under /media/{name of drive} for addons


New question - under my previous pi/ha core setup I edited my fstab file to ensure that the media drive was always see at sdb - does it make sense to do that while using udev

Hello,
Sorry but i’ve not skill :slight_smile:
it’s possible do this procedure with formatted fat32 usbkey?

-I have labled Config the usbkey,
-i put inside a folder with a file named 80-mount-usb-to-media-by-label.rules
-In Ha i,ve import usb data
-unplug usb
-connect hdd usb in the same port and reboot.
It’s all correct?
In media I find nothing :frowning:

why don you use the “Samba NAS” AddOn https://github.com/dianlight/hassio-addons/tree/master/sambanas

it work great and simple to configure.

Just put the exact name like “data” or “Data” (case sensitive) of your HDD label, and it will be auto mount in /media/

1 Like

I just did this, however the mount seems to break if Frigate loads before Samba NAS, because Samba sees that the folder already exists and thus throws an error?

i have the same message because the folder already exist, but the mount work, its more a warning than an error for me.

i followed this tutorial/guide but can’t get it working. i have a EXT4 drive i want to connect. i am importing the udev rules file fine, i get the confirmation in logs. however in SSH i do not have a /etc/udev folder or file.
also, in my HAOS dedicated machine (not virtual!) i do not have anything in the /mnt folder. in the root of the system there is the empty /mnt folder, and also the media folder. I don’t know if this means anything. maybe no one here is running HAOS directly?

I do have the drive listed in hardware though…
image

EDIT: after quite some hours i got it working, turned out to be a spelling mistake in the tutorial i followed.

Thank you very much for the detailed help!
I tried following @promithius instructions, but I got stuck at the last step. I could load the configuration from the USB stick (confirmed in the log), I unplugged the USB stick and plugged in my NTFS formatted SSD. The problem is that I don’t see the SSD in the Media section. I tried rebooting both HA and the Raspberry, neither helped.
I noticed in the Supervisor log that it is somehow seeing the SSD:


But the media section stays as before:

Could anyone please help me figure this out?

I tried formatting the drive to EXT4, repeating all the steps and still no folder showing up in my “Media” section.

For me same thing, i tried to mount it via ssh just to test it. It always said Fileformat unkown on NTFS and EXFAT

Thanks for the tip. I labelled the drive as “data” and it shows up when I remote into the drive. However the recordings are still being stored in media/frigate. It does not get auto mounted into media. Do I have to do anything else?

Just use the Samba NAS Addon from this repository: GitHub - dianlight/hassio-addons: Hassio.io
Configure it with

  • username
  • password
  • automount ON
  • medialibrary enable: true

Format your USB drive EXT4 and name it frigate, plug it in and start the Samba addon.
For me it mounts the drive as /media/FRIGATE ( no clue why all capitals) but I fixed that with a /media/frigate symlink to /media/FRIGATE

Start frigate and it will fill the USB drive.
Also no problems when restarting.

1 Like

Thx!!!
Finally i got it working with you´re description! My flaw was that i didn`t had EXT4 and you´re solution is by far the simpelst way to get it done!

I have the same issue where it is creating the folder as media/FRIGATE. How do you go about creating a “symlink” ? so that it is lower case

Sorry noob here

Thanks

Use SSH to login HA cli (or use Terminal & SSH addon)
type:
ln -s /media/FRIGATE /media/frigate

to check type:
cd /media
and then
ls
you should see two folders now FRIGATE and frigate

The lowercase folder is just a symbolic or soft link to the uppercase

1 Like