Mount remote smb share on hassio

Can you try this:

  1. Remove the direcotry you created
  2. Add this to your shell command (obviously add your passwords etc):
shell_command:
  mount_cctv_media_folder: mkdir -p /mnt/media2;mount -t cifs -o username=idenya,password=Password,domain=WORKGROUP //192.168.1.210/Public /mnt/media2
  1. Add this to the top of configuration.yaml
homeassistant:
  media_dirs:
    cctv: /mnt/media2
  1. Do a physical reboot of the entire server, not just the HA docker container.
  2. Go to Home Assistant->Developer Tools->Services and run the service:
shell_command.xxxxxx (name of the one you made above)

We need to normalise things to help you troubleshoot so the above is how I have mine setup and all works as described.

I found issues with trouble shooting when i was getting into container level CLI, I think you might be right there are permission issues, the above will at least show us what is going on.

Also, stupid question and I do not mean to be rude (i did this myself!!) you do have media in the share you are adding? I tried adding one before i realised how this worked and it actually mounted but becuase i had nothing there it looked like it didnt work because of how the GUI shows you the mount in HA.

2 Likes

I was able to get my samba media directory mounted roughly using this format, however the media browser does not show any thing. I can see the mounted directory and files in the CLI but the media browser says no items. Is there a step I am missing?

I placed a photo in /config/media and then mounted a samba drive to /config/media/shared. When I use the media browser I can see the photo I placed in the directory but I can’t see anything on the shared drive. In the CLI I can navigate and see both.

thank you for replying and trying to help

Have 2 issues,

  1. if i remove mnt/media2 folder - im using such in configuration.yaml my homeassistant would not start (it willbut in safe mode) when the folder exists i can mount manually and all good
  2. why i can’t see the mnt/media2 folder using ssh to docker container, but when i execute a command to mkdir mnt/media2 it says that it exists. wtf

okay i found an answer to the second issue
i should ls / to see the root folder and there is my mount and media and stuff

i think that HA is doesnt have sudo access to that mnt, and just can’t mount it, which he says no such folder (mnt/media2)
So i googled the question, and added HA to Sudoers file using terminal,

Снимок экрана 2020-10-28 в 20.54.33

And… it didn’t help :slight_smile:
still doesnt Auto-mount

And the last thing is
5. 4. Go to Home Assistant->Developer Tools->Services and run the service:

so i went there, put the command inside and it mounted the folder in HA!

then i created a script in script.yaml

#SMBMedia
  shellsmb:
    sequence:
    - service: shell_command.mount_smb_folder

it appeared as a script entity, and configured it to run on startup of HA

BINGO!!! HA is automounting it on start!!!

thanks everyone, maybe my described way will help someone

1 Like

Im Glad you got it working in the end @denveronly

However didnt realise you were not running HA in the HassOS supervisor!

If you are running it on normal docker setup inside ubuntu server for example then there is an easier way to do this that should work.

You basically mount your remote share with the fstab like you would any normal linux system, and then you would pass that volume through to your Home Assistant container if you use docker compose it would look something like this:

volumes:
      - /mnt/share:/mnt/media2

You then create the same shellcommand as normal to get the GUI pick up the directory.

Because (and I believe the guys above also use HASSOS) handles the mount differently to how you would do it if it was a “normal” docker setup. Becase we are using HASS OS as hypervisor not Ubuntu as our operating system.

Personally if I was running Docker in Ubuntu and Home assistant as a container on it, then I would mount your share like you would any other Linux system and then just pass that volume through into your container, this will avoid any messing about with having to try and create that directory inside the container. because docker containers dont have persistent storage unless you specify a volume.

@Ryan_Grandy you will have to give us a bit more to go on here buddy.

How is your HA running? as you’ve seen with @denveronly it makes a bit of difference based on your individual setup.

Also you;ll have to show us what steps and commands/config you are putting in where so we hav a starting point to help you.

I am running HA Supervised on Ubuntu

@nickcj

I am running on hassos which is running in a VM on unraid. I have my media in an unraid share.

I used the following command in the CLI to mount the unraid shared drive:

mkdir -p /config/media/shared;mount -t cifs -o sec=none //192.168.1.xxx/Media /config/media/shared

I also placed a test image in the folder /config/media to see if the media browser works.

This seems to have worked well. In the CLI, when I navigate to the folder I see all of the files and folders on the unraid shared drive, as well as the image I physically put in the folder

image

In my configuration.yaml I added the following items:

homeassistant:
  media_dirs:
    media: /config/media

media_source:

After restarting HA, the media browser appears, however it only displays the image i physically placed in the file, the unraid shared folders and files do not appear. If I go into the CLI, both are available

image

By the way, anyone have an answer about HA media player not playing .avi movies, only mp3 and mp4 video.
mkv files are not visible at all!

I tried to install VLC as an addon, it appeared as an entity and i have nothing to do about it.

@Ryan_Grandy did you manage to solve your issue? Only just got round to catching up on the posts today.

It looks like your actual mount directory with the files is called config/mdia/shared. However in HA you are telling it its in /config/media

Have you tried changing you HA config to this?

homeassistant:
  media_dirs:
    media: /config/media/shared

I dont believe HA has a file explorer function which lets you browse sub-directories? (any one able to confirm that?)

Something odd is happening, any one else experienceing the below?

Just updated my HA to latest version ( 0.117.1) from 0.116, and it booted into safe mode because of the not a directory for dictionary value @ data[‘media_dirs’][‘recordings’] error message in the log.

After I deleted the config line from my yaml and rebooted, everything worked fine (minus the media obviously). However I have then added the media config backin, in exaclty the same location (top of the yaml sheet) and it all worked fine?

Any one else had these issues? Cant replicate it now… so I wonder if I have the same issue on next update.

I had no such issue, but I don’t specify media_dirs in config. AFAIK media_dirs is default included in default_config: , and it also looks into subdirectories of /media
My config is following, I have /mnt/public_m3 mounted, and I have symbolic link from /media/public_m3 to /mnt/public_m3.

mkdir -p /mnt/public_m3;mount -t nfs4 192.168.8.182:/public_m3 /mnt/public_m3;ln -s /mnt/public_m3 /media/public_m3

I can use media browser in HA, and don’t have issues on upgrades.

Did you ever figure this one out? Exactly same configuration as yours. Can mount the network folder fine and can browse it over cli, no problems. but only local files copied into the media folder show up in homeassistant media browser. the mounted folders and files do not show up…

What are the permissions on files inside the shared folder in comparison to folder itself and local files? (ls -la).

1 Like

I have not figured this out yet. Very odd, the guys in this thread are working on the same thing: Point media_dirs: at NAS share?
I couldn’t get it to work with their syntax either, same results.

Let me know if you make any break throughs

Oh I understand now. I was running the mount command in the CLI which mounts the files to HASSIO however HOMEASSISTANT is a separate docker container, so you need to run the command in this container. This is why portainer is used (easy to get a command line to the container).
This is also why the shell command works since it is homeassistant executing it inside its container.

I think this is correct, please anyone correct me if I am wrong. It works for me if I do it this way.

That was it! Damn it, I was mounting it from cli as well but this seems to work well by mounting it from the docker container.

i tried anything.

mkdir create a folder in /media/ like /media/music

but trying to mount on it:
mount: mounting //192.168.0.XX/MUSICA on /media/music failed: Permission denied

i’m using HassOS on Proxmox VM. tried the command on generic linux (ubuntu) and works.

EDIT: after some tests, i see error during send manual shell command and folders are empty in SSH browser, but media borwser works.

1 Like

Hi,
Managed to create/mount nas media folder and add manually, but i cannot make script trigger automatically at homeassistant startup. Where i go wrong ?
trigger: homeassistant
event :start
action: call service
service: shell _command.mount_smbmedia_folder

in scripts.yaml i have:
shellsmb:
sequence:

  • service: shell_command.mount_smb_folder
    in config.yaml i have
    shell_command:
    mount_smbmedia_folder: sudo docker exec -i homeassistant mount -t cifs -o username=xxx,password=xxx,domain=WORKGROUP //192.10.0.101/Multimedia /mnt/media

I ran into this particular issue (“Connection refused”) message when trying to mount NFS share from my QNAP. It turns out, you either have to enable “Enable NFS v2/v3 Service” option for “NFS Service” in QNAP Control Panel. Alternatively force to HA to use nfs v4 using

mount -t nfs -o vers=4  QNAP_IP:/qnap_share /mnt/media

Has anyone successfully been able to pass credentials to mount? I can mount when passing the username/password manually but when I pass credentials it fails to mount.
The command I’m trying to run is

mount -t cifs -o credentials=/config/.ssh/.cifs //10.0.0.20/music /mnt/media

and I’m receiving an error message

mount: mounting //10.0.0.20/music on /mnt/media failed: Invalid argument

Looking under the logs in supervisor → logs → host show:
CIFS VFS: No username specified

I think the credentials command is not being recognized. any idea what I’m doing wrong?