Mount remote smb share on hassio

Hi!

I’m facing the same issue, cannot connect to my Synology via SMB. I tried the following command in my ubuntu (with sudo), and it worked:

 sudo mount -t cifs -o username=Bálint,password=XXXX,iocharset=utf8,rw,file_mode=0777,dir_mode=0777 //192.168.2.110/home /mnt/smb/ -v

Based on previous comments, I tried to execute the command as a shell command with a script (without sudo):

shell_command:
>   mount_smb: mkdir -p /mnt/smb; mount -t cifs -o username=Bálint,password=XXXX,iocharset=utf8,rw,file_mode=0777,dir_mode=0777 //192.168.2.110/home /mnt/smb/ -v

Result is an error code 255, and not even my directory (/mnt/smb) was created.

Do you have any ideas, what should I do? :slight_smile:

Thank’s for any help, this issue is just killing me for several hours :(.

@nickcj The same just happened to me today. After updating to 2020.12.2. it restarted into safe mode with the following: not a directory for dictionary value @ data[‘media_dirs’][‘music’]

My previously-working config looks like this:

homeassistant:
  media_dirs:
    music: /mnt/music
shell_command:
  mount_nas_music_folder: mkdir -p /mnt/music;mount -t nfs <ip>:/share/CACHEDEV1_DATA/Music /mnt/music

Commenting out the 1st 3 lines allowed me to restart normally. Then I uncommented the lines, restarted again, and waited 2 minutes for the Mount Music automation to trigger. I’m back in business, but I’m curious how the upgrade causes this particular configuration to break.

FWIW, before commenting out the lines, I manually created the /mnt/media directory in the homeassistant container using Portainer’s terminal. That still wouldn’t pass validation even though the directory existed. The only way I was able to recover my media is to first comment it out, restart, then put it back in and restart again. Thanks @nickcj for giving me the answer.

2 Likes

@tanderson1992 I wonder if its worth while tagging this as a bug?
Out of interest what are you running your HA on? mine is an intel NUC running with HASS OS hypervysor.

Does anyone else have this issue?

1 Like

I submitted it as a bug here, noting that it was previously reported but not addressed because the reporter didn’t properly fill out the bug template. My bug was closed within 2 hours with a developer saying it’s not a bug because mounts must be handled outside HA. He didn’t seem to fully grasp that mounts only need to be handled outside HA for one reboot cycle, and then they can go back to working just fine. I commented on the bug, but I don’t have the ability to re-open it.

Also, mine’s HA Supervised on an RPi4, mounting a share from a QNAP NAS.

Not an overly helpful reply by frenck.

Basically, it seems you are runnig similar setup using hass OS.

If the “issue” is because mount doesnt exist due to the way that HA upgrade/upadte works vs to just a generic reboot.

How do you handle the share mount outside of HA within the hypervusor? its still an HA issue since there isnt a way to handle this from my understanding and nothing mentions this in the HASS OS documentation.

I’ve commented back to your bug post, lets see if Frenck replies with some pointers, we just need to be able to create the mount outside of the HA container, rather than boot container, then create mount which makes perfect sense and how i originally trried to do this but HASS OS wouldnt let you.

EDIT: After insisting Docker containers can’t access OS mounted drives, frenck indicated I was wrong. Sure enough, containers can be started with bind mounts. In fact, according to Portainer HA starts with 9 folders bound to system folders. I’m going to try mounting my media to OS /mnt/music and then binding homeassistant’s /media/music to the system /media/music. That might negate the error @nickcj and I experienced, as well as allow for easier mounting of the volume via the OS’s /etc/fstab.

It seems like we’re not getting much traction on the bug, and I’ve already spent more than 10 times the amount of time than was required to fix it in the first place. I’m not running HASS OS. I can mount shares on my OS, but because HA is in a Docker container, it can’t access shares mounted on the OS.

I’m just going to file this away until the next update, and hopefully will remember then to take out the configuration for one reboot cycle before putting it back in. Code shouldn’t work that way IMO, but if the developers think that’s how code should behave, I’m not skilled enough to rewrite it for them.

As a matter of fact, now I’m going to write an automation that notifies me to edit the configuration whenever the updater is triggered :slight_smile:

2 Likes

Ah yes, then if you are not constrained by the HASS OS like me, you can totally bind mount the folders you want and then reference them in the HA config! your problem is thus solved and you wont ever need to worry about that line of code.

Agree on the bug report, Frenk is missing my point but i cannt be arsed to spend more time talking about it on there with him, point is HASS OS doesnt support mounts and you cannot use this feature fully basically without removing the code etc.

I used to run my HA in docker on my own OS and I may revert back to that mode, the fact that there is little interest to document the limitations of HASS OS is really bothersom and ends up being so time consuming where you just end up chasing your own tail for a fault which is actually just not a thing that is supported but not documented to say what is supported.

Rant over. Hope you get to sort your mounts out, if you want a hand with Docker give me a shout.

1 Like

Hello. I did this i the terminal addon in home assistant:
mkdir -p /config/media/tv;mount -t cifs -o sec=none //192.168.10.103/tv /config/media/tv
But all i get is permission denied. What im i doing wrong?
/Jerry

Out of curiosity, would you guys like a run-on-startup add-on? I could easily make something that would be configurable from the UI and easy to start/restart and test.

Eg. https://github.com/adamoutler/HassOSConfigurator

7 Likes

I’d be keen on ANY way to get access to my music which is on my NAS via the HA media browser… (preferably able to do it using HassOS)

It seems absolutely crazy to me that such a function wasn’t included in the original release of this component, I mean who wants to save all their music on their HA server? For some people that’s a RPi3. I don’t even want to on my i7 NUC, that’s what my NAS is for.

5 Likes

That would be an awesome addition!

I’m working on it

3 Likes

That is amazing! thanks @adamoutler

Hey guys, this is totally unstable, meaning configuration will change within a few days, and you’ll need to rename your startup.sh file, but you can try it if you would like.

Add this repo and use the run on startup configurator.

It’s absolutely required to “Disable Protection”. This jumps out of its own container to execute under a different container.


On first run, it will create a file accessible from samba or ssh in /config/startup. The contents of the startup.sh file will be run under the Home Assistant container by default. However, you can change that to run under any other container by modifying the container name under configuration.
image

If you try it, please report your results.

Thanks!!

But, I’m a little unclear on how this works. I see from the above (but not the documentation on GitHub) that it creates a startup.sh file in /config/startup. Presumably, we’d put mount commands there? Any examples?

And it can be uninstalled after the first run. Again, presumably because whatever it left behind in the base OS is still there. Will that be impacted by OS updates? Will I need to install it again?

Sorry for the dumb questions, I really want to try this, but first I want to understand what I’m doing - at least a little.

1 Like

Hi, The project evolved a bit and I didn’t update this thread. It’s called Run on Startup.d, and it creates a per-machine startup script.

In this example, I’m using the Samba Add-On.

On first run, it will create config/startup/logs, and /config/startup.dimage

If you choose “Create example”, it will create a script for each container on your machine and execute them. You can find the logs in /config/startup/logs
image

Additionally, logs are available in Web UI. Here you can see I just installed AppDaemon and it has no logs available. The SSH addon had the example script executed and you can see this here.

You can then delete all the items you don’t care about from /config/startup/startup.d, then modify the scripts to run the commands you want, when this addon is started.
image

Personally, I have just one script for my Home Assistant container, which I wish to keep private.

3 Likes

Not sure if this will help but the below command works for me on Hassio, just needed to go to services and run shell_command:mount_emby_media_folder after I rebooted HA.

shell_command:
  mount_emby_media_folder: mount -t cifs -o username="USERNAME"password="PASSWORD",domain=WORKGROUP //172.16.1.100/media/Music /media

I can’t get this to work =( Any tips?
I can connect from other devices.
Script doesn’t even create the /mnt/cctv

configuration.yaml

shell_command: 
   mount_nas_media_folder: mkdir -p /mnt/cctv;mount -t cifs -o username=<myuser>,password=<mypw>,domain=WORKGROUP //<ip>/shared /mnt/cctv

automations.yaml

- id: ha_start_event 
  alias: HomeAssistant Start 
  trigger:
   - event: start 
     platform: homeassistant 
  action: 
   - delay: 00:02:00 
   - service: shell_command.mount_nas_media_folder

and this is the log:

[ 6809.244638] CIFS: Attempting to mount //<ip>/shared 
[ 6809.244663] No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount. 
[ 6809.244767] CIFS VFS: Error connecting to socket. Aborting operation.

Hey everyone, I feel like I’m really close, I just need a little help getting over the finish line. I am running Home Assistant OS on a Raspberry Pi 4 and trying to mount my Synology Diskstation’s music folder.
Here are the steps I took so far:

  1. Setup configuration.yaml like below. Trusted network IP is that of the Synology Diskstation. media_dirs is commented out right now because it doesn’t exist yet. If you do not comment out the media_dirs the code will not validate. Replace myusername and mypassword with your own credentials. Domain is set to WORKGROUP by default in Synology > Control Panel > File Services, screenshot below shows where the settings are.
homeassistant:
#  media_dirs:
#    music: /mnt/media2
  auth_providers:
  - type: trusted_networks
    trusted_networks:
      - 192.168.1.26

shell_command:
  mount_synology_nas: "mkdir -p /mnt/media2;mount -t cifs -o username=myusername,password=mypassword,domain=WORKGROUP //192.168.1.26/music /mnt/media2"

  1. Do a full system reboot of the Raspberry Pi, not just the OS. After Home Assistant came back up I went to Developer Tools > Services and called the service Shell Command: mount_synology_nas. I clicked the button a couple of times, there doesn’t seem to be any indicator of anything happening. I went into Home Assistant’s Terminal within the left side navigation and typed ls, but did not see the media2 directory like I had expected.

  2. Now I uncomment the media_dirs lines within configuration.yaml. It now looks like this & validates!

homeassistant:
  media_dirs:
    music: /mnt/media2
  auth_providers:
  - type: trusted_networks
    trusted_networks:
      - 192.168.1.26

shell_command:
  mount_synology_nas: "mkdir -p /mnt/media2;mount -t cifs -o username=myusername,password=mypassword,domain=WORKGROUP //192.168.1.26/music /mnt/media2"
  1. Restart the OS, I did not do a full reboot of the Pi this time. Upon starting back up, I can see media2 is the default folder, but nothing is appearing.
    Screen Shot 2021-03-07 at 1.18.28 PM

Within Home Assistant OS I checked Supervisor > System > Core logs and saw this:

ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `mkdir -p /mnt/media2;mount -t cifs -o username=myusername,password=mypassword,domain=WORKGROUP //192.168.1.26/music /mnt/media2`, return code: 111
NoneType: None

Does anyone know what error code 111 means? I believe I’ve created the media2 directory but the Synology is failing to mount, so that’s why media2 appears empty. If I can figure this out I plan on doing a YouTube video tutorial to help everyone else out.

UPDATE 1: I found a post about error code 111 and tried adding -o sec=ntlmv2 to my shell command. So now the shell command looks like:

shell_command:
  mount_synology_nas: "mkdir -p /mnt/media2;mount -t cifs -o sec=ntlmv2 username=myusername,password=mypassword,domain=WORKGROUP //192.168.1.26/music /mnt/media2"

Restarted Home Assistant OS, called the service, checked the core logs, and now I’ve got another error message:

2021-03-07 13:32:17 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `mkdir -p /mnt/media2;mount -t cifs -o sec=ntlmv2 username=myusername,password=mypassword,domain=WORKGROUP //192.168.1.26/music /mnt/media2`, return code: 1
NoneType: None

Still unsure how to solve this.

UPDATE 2: I had to reboot the Pi after other unrelated changes I made, and Home Assistant booted into safety mode because when rebooting the media2 folder that I had created no longer existed and the configuration.yaml was referencing that folder. I used the built in file editor, commented out those lines, and started back up safely. I now see the need for using portainer to create the directory. I used these instructions on setting up my new folders. After rebooting the Raspberry Pi, these folders are still not appearing. Any suggestions as to what I am missing?

I’d assume that’s because the browser doesn’t support such files.

You mean VLC integration, not an addon. Because the integration is supposed to remotely control a VLC instance running somewhere.