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

I did this and everything on rules.d is deleted. I didn’t see any problems though.

Hello All,

How can i set destination path for transmission add-on, which mounted disk as described above.

Thanks

Hello,

This is my first time comenting on a forum, but i’ve read every single comment on this thread and pretty much tried everything. I solved my first problem which turns out what was wrong on my end was a typo on the rules.d file that I changed when switching out lines 24 and 50.

My current problem is as follows. EVERYTIME my system reboots (it reboots once daily sometimes for some strange unknown reason) or I connect my external drive (2 TB WD My Passport), i get a message saying:

“21-04-08 23:33:44 INFO (MainThread) [supervisor.hardware.monitor] Detecting HardwareAction.ADD usb hardware /dev/bus/usb/002/002”

Which is normal, but after a while (sometimes seconds, sometimes minutes) I get the following message without doing anything:

“21-04-08 23:34:21 INFO (MainThread) [supervisor.hardware.monitor] Detecting HardwareAction.REMOVE usb hardware /dev/bus/usb/002/002”

This process repeats several times automatically until it no longer detects the usb even though it is still connected and I physically have to remove it and plug it back in. it is really annoying because I can’t access the files and don’t know what else to do. Does someone know what is the problem here?

Hi All,
I have issues with this solution:
The import from USB function doesn’t work for me (the usb was formated to fat32). At the end I manually copied the file to /etc/udev/rules.d. After plugging the external drive, it was mounted automatically.
BUT: when I restarted the host (rpi4) it doesn’t start. If I remove the external drive the system can start. I removed the rule file, but the system can’t boot with external drive :disappointed:.
Ups: the issues was that the external drive was plugged into the USB3 port.
(My system also runs from an SSD at USB3). I still can’t figure out why does work it only with USB2.
Any suggestion?
Thx:
P!

Does this still work??
My problem is that the rule disappears upon every reboot.

  1. created /etc/udev/rules.d and put the 80-mount-usb-to-media-by-label.rules file in there. Gone upon reboot. Infact the whole udev folder is gone in /etc.
  2. used Docker: docker container exec -it homeassistant /bin/bash
    created it there and put the file in there. It’s still there upon reboot, but isn’t mounting the usb drive formated ext4. (Note: drive has no label and no CONFIG folder)

dmesg:

[  719.509071] usb 1-1.4: New USB device found, idVendor=13fe, idProduct=6300, bcdDevice= 1.10
[  719.509095] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  719.509114] usb 1-1.4: Product: USB Flash Drive
[  719.509132] usb 1-1.4: Manufacturer: Philips
[  719.509149] usb 1-1.4: SerialNumber: 0721070B92FF8830
[  719.515010] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[  719.522541] scsi host0: usb-storage 1-1.4:1.0
[  720.557959] scsi 0:0:0:0: Direct-Access     Philips  USB Flash Drive  PMAP PQ: 0 ANSI: 6
[  720.560619] sd 0:0:0:0: [sda] 241975296 512-byte logical blocks: (124 GB/115 GiB)
[  720.561406] sd 0:0:0:0: [sda] Write Protect is off
[  720.561430] sd 0:0:0:0: [sda] Mode Sense: 45 00 00 00
[  720.561949] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  720.679512]  sda: sda1
[  720.683428] sd 0:0:0:0: [sda] Attached SCSI removable disk

df -h: 
Filesystem                Size      Used Available Use% Mounted on
overlay                  58.0G      5.3G     50.3G   9% /
tmpfs                     1.9G         0      1.9G   0% /sys/fs/cgroup
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /ssl
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /config
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /media
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /share
devtmpfs                  1.8G         0      1.8G   0% /dev
tmpfs                     1.9G         0      1.9G   0% /dev/shm
tmpfs                     1.9G         0      1.9G   0% /tmp
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /run/audio
tmpfs                   765.1M      1.3M    763.8M   0% /run/udev
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /etc/asound.conf
tmpfs                   765.1M      1.3M    763.8M   0% /etc/machine-id
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /etc/resolv.conf
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /etc/hostname
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /etc/hosts
tmpfs                   765.1M      1.3M    763.8M   0% /run/dbus
/dev/mmcblk0p8           58.0G      5.3G     50.3G   9% /etc/pulse/client.conf

I can manually mount from docker though.

1 Like

hello @Wonitoma ,

nice solution! because it doesnt work for me too…

can you give me your script config please?

thanks!

@paoloantinori @petikeje @goldbowler @Morphy @mutlu @FreakZAR @sparkydave

right, all work at the first attempt, just nothing in the media/newfoldercreate, after the first reboot, it works!!!

BUT after a 2nd reboot nothing works, rules have gone…

any idea please?

So bad, its a nice solution if it will be persistent…lol

and manually it works :

docker container exec -it homeassistant /bin/bash
mount /dev/sdb1 /media/usbstoragelocal

but how make it permanent? i try hours and hours with ssh&terminal addon from @frenck with no luck, i mean manually in the Terminal, it works, but has gone after a reboot, so i try in init_command, errors…try an automation with hassio.stdin threw the ssh addon…errors…

If any good people can help, it would be appreciate…thanks

This was a bit of a struggle, but I managed to figure this out and piece the puzzle together. The gist linked in the original post by OP does what it needs to, using udev, but there’s a couple of gotchas.

I summed it up in a reply - https://gist.github.com/eklex/c5fac345de5be9d9bc420510617c86b5#gistcomment-3883119

1 Like

Just been looking for exactly this, awesome. Will be upgrading my NUC to one with an M2 + a SATA drive and want to mount the SATA to media for Frigate clips.

1 Like

Did you succed in doing so?
Tried it but is seems the SATA drive is not mounted (at least, doesn’t look like it when checking with “df -h”)
BTW - is there a way to mount the SATA drive to a specific folder inside Media?
I’d like only the recordings of Frigate to be saved to the SATA HDD, all the rest of the media to be saved to the NVMe…

1 Like

I’m still looking at it. Just got my new (2nd hand) i3-6100 Brix so will be moving my HA install at the weekend. Will let you know how I get on.

So I’ve just moved my HA installation over. I’ve managed to mount the the SATA drive under /media/storage following this process: https://gist.github.com/eklex/c5fac345de5be9d9bc420510617c86b5#gistcomment-3883119

I connected monitor/keyboard to my nuc and followed the instructions, finding my uuid and then using vi to create the 80-rule. Just testing it now, but appears to work. Next step is to see if I can actually mount it to Frigate.

:EDIT: OK, changed the 80-mount rules file to mount directly into
/mnt/data/supervisor/media/ and…
IT WORKS! Frigate is now recording directly to my SATA drive as evidenced by the increasing df -ah output from the terminal.

3 Likes

You can also get host / access with docker run -it --rm -v /:/mnt alpine sh via the terminal ssh add-on.

1 Like

Works perfectly, thanks

This works in Home Assistant OS 7.2, Home Assistant 2021.12.10

Thank you. I’ve been like 6 hours now figuring out how to mount an external drive. It seems crazy to me that this isn’t plug and play…

Those who say this isn’t needed because HA is not supposed to be a media server… okay (ugh). Still, plugging a USB drive and see the files is pretty basic, even if “you” don’t want to use it as a media server.

Thanks again for the steps!!!

2 Likes

Hi all I posted in the github but thought more people may be active here (apologies for double post)

I realise i might be making a mistake, my harddrive is added to VM via USB passthrough. I am detecting the UUID

lrwxrwxrwx 1 root root 10 Feb 3 23:05 36071622-61b5-4f69-bab3-27e03c46357d → …/…/sdb1
lrwxrwxrwx 1 root root 10 Feb 3 23:05 5d7db345-f084-4204-a905-999f5e35fdd6 → …/…/sda8
lrwxrwxrwx 1 root root 10 Feb 3 23:05 7cefb21e-124e-4280-ba29-34fc7a04d19b → …/…/sda7
lrwxrwxrwx 1 root root 10 Feb 3 23:05 FFF7-ADD4 → …/…/sda1

lrwxrwxrwx 1 root root 10 Feb 3 23:05 pci-0000:00:07.0-ata-1.0-part1 → …/…/sda1
lrwxrwxrwx 1 root root 10 Feb 3 23:05 pci-0000:00:07.0-ata-1.0-part2 → …/…/sda2
lrwxrwxrwx 1 root root 10 Feb 3 23:05 pci-0000:00:07.0-ata-1.0-part3 → …/…/sda3
lrwxrwxrwx 1 root root 10 Feb 3 23:05 pci-0000:00:07.0-ata-1.0-part4 → …/…/sda4
lrwxrwxrwx 1 root root 10 Feb 3 23:05 pci-0000:00:07.0-ata-1.0-part5 → …/…/sda5
lrwxrwxrwx 1 root root 10 Feb 3 23:06 pci-0000:00:07.0-ata-1.0-part6 → …/…/sda6
lrwxrwxrwx 1 root root 10 Feb 3 23:05 pci-0000:00:07.0-ata-1.0-part7 → …/…/sda7
lrwxrwxrwx 1 root root 10 Feb 3 23:05 pci-0000:00:07.0-ata-1.0-part8 → …/…/sda8
lrwxrwxrwx 1 root root 9 Feb 3 23:05 pci-0000:00:1d.7-usb-0:1:1.0-scsi-0:0:0:0 → …/…/sdb
lrwxrwxrwx 1 root root 10 Feb 3 23:05 pci-0000:00:1d.7-usb-0:1:1.0-scsi-0:0:0:0-part1 → …/…/sdb1

But i don’t know enough about the script to know if it discriminates to only use sata as per the original intent

KERNEL!=“sdb[0-9]”, GOTO=“abort_rule”

ACTION==“add”, RUN{program}+="/usr/bin/systemd-mount --no-block --automount=no --collect /dev/disk/by-uuid/36071622-61b5-4f69-bab3-27e03c46357d /mnt/data/supervisor/media" ACTION==“remove”, RUN{program}+="/usr/bin/systemd-umount /mnt/data/supervisor/media"

LABEL=“abort_rule”

also after saving this script, do i just need to restart the system or do i need to update some reference?

any help would be great thanks

Is there any easy way to get that working on my Home Assistant Blue Odroid?

1 Like

Hi @paoloantinori ,

Thank you very much!

I followed your toturial and my usb drive now mounted to HASSOS successfully and it works perfectly.

I have a question about this solution, is it possible to automount usb drive when HASSOS boot up?

I have followed your instructions and have successfully mounted my exfat formatted hard drive. But I am unable to see any content in the media folder where the drive name is showing up. None of the folders inside are showing up. I have restarted my HA, even rebooted my host. I am at a loss to what I should do next? Anyone have any ideas? I know it has to be something small.

Again thanks for writing such detailed instructions

Did you tried it on the Blue Odroid?
Also running my HASS.IO on the Blue and want to connect an external SSD for storing the recorder DB.
Sadly HA 05/2022 has removed the abillity to use SQLITE in memory for recorder.

thx