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

I just downloaded the file

https://gist.githubusercontent.com/eklex/c5fac345de5be9d9bc420510617c86b5/raw/d7010307ccee5c904c2a79f345680ffe6c6651bf/80-mount-usb-to-media-by-label.rules

and stored it in this directory

/lib/udev/rules.d
Restart
And it worked

1 Like

So I just hooked up a KB and monitor to my Pi running Hassos because I could not figure out how to ssh into my ssh add-on and escape the ssh container that would allow me to get to the host folders to pull this off.

I’m now on the host but when I try to copy the file to /lib/udev/rules.d on the host I get “Read-only file system” error. Any idea how I can get around this?

I am using


Protection mode disabled

Sorry
Have to look in to this again, made a mistake somewhere .

Thanks for your reply. I am using a different add-on for SSH. Just to clarify, are you saying that the one you use will allow me to escape the add-on container or otherwise get access to the host folders that I need?

When am in. I am using this command to get into the running docker ha.
docker container exec -it homeassistant /bin/bash

From there I can mount the usb stick using

mount /dev/sda1 /media/usb-sda1
First I got an illegal argument error, fixed that formatting the stick first using
mkfs.vfat /dev/sda1

This command helps
dmesg | grep sda

2 Likes

Just realized there is a another way .
Connect usb stick
Goto
Supervisor=> system=> host . Hamburger menu
Find our the new device name
Fi
/dev/sda1
Use ha automation to execute a command line switch
The switch mounts the drive.

alias: mount my usb
description: ‘’
trigger:

  • platform: homeassistant
    event: start
    condition: []
    action:
  • service: switch.turn_on
    data: {}
    entity_id: switch.mountusb
    mode: single
3 Likes

I was thinking a lot of scenario until saw your post,

Thanks A lot

I tried some of the things in this post (the udev rule and the automation). It worked great but I think it’s a complicated way to solve a simple problem.

I ended up using the Samba NAS addon from https://github.com/dianlight/hassio-addons. It’s simpler to manage and it works for my need which is to use the drive with the Plex Media Server NAS (same repo).
I advise anyone having a similar need to mine to give it a try before setting up stuff that’s gonna be hard to deactivate/remove.

1 Like

Did you figure this out? Also, how do we go about un-mounting the drive for removal? Thanks for your help!

I have successfully mounted my usb drive with your instruction. I am able to write and remove to/from the fat32 drive partition with samba. I have also configured my cameras to write to the mounted directory through FTP. Logs show successfully created files. But i don’t see them in that directory. Neither I can see automatically created folders. Is it the limitation? What am I doing wrong? How can I fix it?

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