[Solved] Hassio and volume mount issues

Hi all,
I can only see ‘/’ from within hassio which refers to the folder ‘/usr/share/hassio/homeassistant’ under ubuntu because of docker container. I need to reach to some other folders on ubuntu from within hassio, due to some requirements. Like:

  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /
#      - type: disk_use_percent
#        arg: /media/hdd
#      - type: disk_use_percent
#        arg: /media/plex
      - type: memory_use_percent
      - type: processor_use

And of course i can’t use the lines marked with ‘#’ . As i searched for this issue, i see that i need to use bind mount on homeassistant docker container. As i am not docker competent, i tried to use portainer for this; but as i understand i cannot bind mounts on a working homeassistant container; because i can’t see any active bind mount config page on this container. Do i need to duplicate ha container, handle bind mounts and then use this container instead? Can you guys show me how to handle this?
Thanks…

UPDATE: Is adding ‘/media/hdd’ to ‘/etc/systemd/system/hassio-supervisor.service’ makes sense?

    docker run --name hassio_supervisor \
        --privileged \
        $APPARMOR \
        --security-opt seccomp=unconfined \
        -v /var/run/docker.sock:/var/run/docker.sock \
        -v /var/run/dbus:/var/run/dbus \
        -v "${HASSIO_DATA}":/data \
        -e SUPERVISOR_SHARE="${HASSIO_DATA}" \
        -e SUPERVISOR_NAME=hassio_supervisor \
        -e HOMEASSISTANT_REPOSITORY="${HOMEASSISTANT}" \
        "${SUPERVISOR}"

like:

-v /media/hdd:/external \
1 Like

In order to achieve this; i was trying to mount volume to homeassistant container. Some suggested that i should clone homeassistant container, mount the necessary volumes and use this container instead. As i was saying i am not that good with docker issues; so was searching for an alternative method. I came across this https://stackoverflow.com/questions/28302178/how-can-i-add-a-volume-to-an-existing-docker-container ; and the 3rd answer was the thing i was looking for.

In order to mount-bind an external volume to the existing container; you can follow these steps:

  1. From portainer or any other means; find the folder of homeassistant container (Containers stay at folder : /var/lib/docker/containers/ . Under this folder there are folder names like b1094552678378ac7878 etc. Find the corresponding folder.
  2. (As root) Stop the docker service:
$ service docker stop
  1. Inside the container folder, open config.v2.json with nano, vi, vim etc.
  2. Find the “MountPoints” part inside the json, after “/config”, “/share” and “/ssl” mount points which are already there add your volume here like:
"/extfold":{"Source":"/media/temp","Destination":"/extfold","RW":true,"Name":"","Driver":"","Type":"bind","Propagation":"rprivate","Spec":{"Type":"bind","Source":"/media/temp","Target":"/extfold"},"SkipMountpointCreation":false}
  1. Also add your add your volume name here inside the json:
"Volumes":{"/config":{},"/share":{},"/ssl":{},"/extfold":{}}
  1. Save this file
  2. Restart docker service or reboot the server.

When the ha starts up; you can use this new volume in your configuration.yaml or scripts or automations like:

  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /
      - type: disk_use_percent
        arg: /extfold

IMPORTANT:
Please understand that i accept no responsibility for any problems that may arise from doing this procedure. I am in the testing phase for now; will inform you after i test everything.

EDIT: You have to renew this procedure everytime you update HA, since a new docker container is created for the new version HA.

6 Likes

Hi Erkan,

I’m having some difficulties getting this to work. Is it still working for you? My main goal is to be able to save snapshots/records from my cameras onto my NAS from hassio (technically Home Assistant Core now). I made the changes in the config.v2.json file but when i restart the containers, the folder still shows up empty in the HA File Editor. I currently map my NAS drive on my Ubuntu VM to /mnt/cctv, and added the the destination to be “/cctv” in the json file.

Any help you could provide would be great. Thanks!

1 Like

Could be related to linux permissions and/or mountpoints RW issues. If you can send your config.v2.json file in a private message i can have a look at it…

Thanks, I just sent you a message with the code. Hopefully that work for you

Hi,

I’m trying to implement this in my RPI3 but I’m not familiar with this.
I’m stuck in the first step, I’m trying to use Portainer addon.
It is possible to do some snapshots using Portainer so I and other like me can implement it?

Go to Portainer; Select Primary and then select Conatiners (Or directluy select containers in the Portainer side menu. Then go find Container named ‘homeassistant’:

Then mouse click the name ‘homeassistant’. Then this screen comes up:

The id name is the folder name under /var/lib/docker/containers

1 Like

you can try use “mount - bind”
i.e. mount -o bind /media/foldername /media file location/media/

Just in case somebody need

Running HA OS inside VM.
Changes of config.v2.json are lost after reboot of Home assistant OS.
Any idea how to keep them persistent?

Used this solution but I had to restart the server after editing the file - starting docker again wasn’t enough. But it seems to be working , thanks alot @febalci !

1 Like