Mount remote smb share on hassio

If I remember good 2 years ago I found that would be possible make cifs mount accessible to hassio and any container if bind-propagation of addon container options was changed to rshared (if I remember good) to make possible do a mount cifs inside a container in bind subfolder and make visibile on all container but when I propose to add optional bind-propagation setting to hassos/hassio developers rejected it.
Accepted only cifs on kernel as module to make possibile mount it on single addon itself (that load it and add also cifs-utils).
Sorry for my bad english and hope this can help if someone want try to do the change and repropose to developers.

There’s actually no need to mount within a container. And it won’t work unless --cap_add is at sys_admin or the container is run with --privileged. This is why people are getting permission denied when trying to mount in the ssh_addon container. homeassistant container is built with privilege and label disabled. Most other containers are not.

That being said it’s fairly easy to mount over a network when running HassOS but you’ll have to manually run a script each time you boot HassOS as there is no mechanism for running a command after it boots. From what I can see the only way to run a command after HassOS boots is to “unsquash” the root file system and modify with then rebuild it like urko did in this thread.
This is a lot of effort and it’ll be blown away next time HassOS gets updated. I think there is no control over updating HassOS, it’s all done automatically and in good faith. Really people should run their own supervisor and HA core on a distro/whatever

HassOS also has no NFS support available but does have CIFS tools and module. With that you can mount a CIFS/SMB share on a HassOS writable mount that is already passed to containers.

Example vmware image running HassOS.
/dev/sda8 is mounted on /mnt/data as RW
containers are built with /mnt/data/supervisor/media passed
mount cifs share to /mnt/data/supervisor/media
restart containers that need cifs mount

Example script located in /mnt/data:

#!/bin/bash

mount -t cifs -o username=someuser,domain=somedomain,password=somepassword //1.1.1.1/NVR_Storage /mnt/data/supervisor/media

CIFSCONTAINERS=“hassio_cli addon_ccab4aaf_frigate addon_core_ssh homeassistant”
for x in $CIFSCONTAINERS ; do
docker restart $x
done


Then tada cifs mount in HA and all your addons that use the mount point. Pretty clunky but it works.

You can find containers that you want to add the mount with:
docker ps --format “table {{.ID}}\t {{.Names}}”

also probably want to stop addon containers at boot and manually start them as to not clobber the mount point.

The script has to be manully run each time HassOS boots. I looked in to using UDEV but udev runs very early and kills any scripts by the time docker starts. I couldn’t find any other way (apart from unsquash) to run a script after booting.

When HassOS updates the shell script may get overwritten in /mnt/media or not.

I also looked in to using a nfs/cifs mount in a docker volume and trying to run that to a container with no joy and messing around with containers hostconfig.json files made me lose motivation.

1 Like

i made a script, to make it easier. But still after core/supervisur update sometimes it gets overwritten. Sometime no. Still i’m updating HASS 1x/2-3month. so not a big deal for me.
But there is an issue on github where guyz are working on mounting remote share and have some GUI for it. So in the future it will be, but not now.

Yeh it is what it is at the moment… I’ll be moving to a dedicated VM at some point in the future.

A little off topic but I wonder how often hassos gets updated. i couldn’t see a release cycle.

A little more off topic, if your environment like mine, is behind a restrictive firewall and doesn’t allow external ntp requests (udp/123) i.e. you run your own internal time server, you can decrease the boot time of hassos by putting your internal time server in /etc/systemd/timesyncd.conf

This knocked off ~90 seconds off boot time as the script will not timeout trying to connect to cloudflares ntp server. Look for where it sits at “waiting for kernel time sync” or something like that

Nice if you reboot it frequently :wink: Hack on :+1:

There is a cycle like every week or two. Nevertheless no need to update to have the latest fancy. Just do once per 2 month and its fine ))))
Personaly i never had problem with boot time :-X

hi!

you can try this ( for HassOs users only ), work great!

https://community.home-assistant.io/t/new-addon-samba-nas-mount-external-disk-and-share-it/172193/205?u=olivier974

does this work with a remote cifs mount? Or just a local attached disk?

Hey all,

i am running Homeassistant OS as VM on my ESXi. Tried all ways (except the one described by urko and reedy to “unsquash” the root file system)

Thats of course a solution i would like to avoid. My overall target would be to use mount a folder which i can use in the HomeAssistant media browser.
Do anyone else see another chance to do that?

p.s. already upvoted the feature request

Thank you for the upvote! <3

But now with the script it is much easier.
And as from what i can see,that on one partition the fstab stayes and is not overwriten.
So i can maybe change the script to check if exists already and just inject to another partition.Will see next update.

Please vote for my feature request:

2 Likes

Why to seperate feature request? it would not make any sence, just vote on my FR will post link
I have 42

Well I didn’t find a FR when I searched

1 Like

pls if you can delete D: it would be awesome D:

Anyone have issue/feature request where the devs have said if/when this will be worked on ?

I’ve found this interesting part in the blog post of the release of hasOS6

OS AGENT
Operating System release 6 comes with a new, Go written daemon called OS Agent. This allows the Supervisor to access more aspects of the OS. One such aspect is to move the data to an external data disk or wipe data to start over without reinstalling. Note however that at this point, the required logic in the Supervisor and Frontend is still being developed.

So I guess they are aware of the issue and might already be working on it ? I’ve read a bit about buildroot which they seems to use. There’s plenty of way they could allow us to do the configuration at the OS level, it’s not “that” complicated, they are probably looking to deliver a full feature with WebUI support and everything… The Buildroot user manual

I don’t have any experience with Buildroot… I’m trying to find if there’s trace of something we could use to run a mount that doesn’t require to rebuild the squasfs… operating-system/buildroot-external/scripts at dev · home-assistant/operating-system · GitHub

The thing is when you have HA OS and you change the script after update the script is gone.
I have been that road with buildroot-external . The only thing that its possble there is a ticket on github reguarding fuseos but there are no developers on it. We need to wait for looooong time :>

The one thing that they could have done is to remove cleaning script to not delete the fstab. But they cant, i have a discussion on github with them

1 Like

Thx for the info, could you share the issue with us ? I’ll follow it at least to see if something move one day :stuck_out_tongue:

1 Like

Cheers :stuck_out_tongue:

2 Likes

Thank you very much. The ’ ’ around the shell_command did the trick for me :-). This is missing in a lot of other threads!

1 Like