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.