Mapping USB hard disc in docker (Ubuntu)

Hi!

I just installed Hassio with Docker in Ubuntu following the Hass.io install commands:

sudo -i
apt-get install software-properties-common
add-apt-repository universe
apt-get update
apt-get install -y apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat
curl -fsSL get.docker.com | sh
curl -sL “https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh” | bash -s

Everything is working fine.

I´m trying now to get access to my hard drive attached to an USB port but I don´t know how to do it. I don´t understand how this docker works really. I am quite noob with docker.

I want to save the bigs files created by my cameras into that hard drive

Can someone help me to gain access to usb ports?

Best regards

On Ubuntu you create a mount point, fstab the USB drive to that mount point, and use bind mounts in docker to pass the location through…

Or mount it in a directory inside /usr/share/hassio and your hassio container will have access to it.

And how can I do that? what commands? and from where? from Ubuntu or indide Hassio through terminal in Hassio?

You go to your favorite search engine and look up how to mount a USB in Ubuntu?

Well since I said in Ubuntu…

Hassio terminal doesn’t do anything for the host OS

Hi,

i did what suggested and mounted a remote folder in

/usr/share/hassio/config/www

but when remotely logging in by ssh to hass.io i just see the folder as “symbolic link” and can’t access it.
Any advice?

Why are you logging into ssh on hassio?

I have an automation which save a picture from camera stream on that folder but it fails to save it.
I am logging in to hass.io simply for debugging purposes: I can ‘cd’ into the folder from that

sounds like a permissions issue to me then.

ah thanks…I will have a look and let you know!

thanks again the meanwhile

ok so i checked permissions but it still does not work.

if i ssh to Hass.io I see this my folder “camera_save” own to root and has

drwxr-xr-r

permissions
if I log on the host system (where NFS folder is mounted) I see:

4 drwxrwxrwx 7 root root 4096 mag 5 11:34 camera_save

which should be fine.
On host system I can access the folder and write on it with a user different from root hence I believe again should be fine.

If i log into Hass.IO and try to:

cd camera_save

I get

cd: symbolinc link loop: camera_save

which i don’t know what it means.
@flamingm0e can you help?

Have you tried chmod -R 777 /path/to/directory from within hassio?

hi,

so I restarted from scratch.

  • Removed the network mouting from fstab and rebooted
  • Deleted the folder /usr/share/hassio/homeassistant/www/camera_save
  • Recreate it and chmod -R 777 camerasave
  • Re-added to fstab
  • From host system confirmed it is drwxrwxrwx 7 root root 4096 mag 18 10:34 camerasave

still i can’t access if I ssh to HassIO and i get
cd: symbolinc link loop: camera_save

what am I doing wrong?

I found this which looks relevant but it is beyond my understanding if it can help to fix my situation

I’m confused on your order of operations.

Are you shutting down the container first? You have to have it mounted BEFORE starting the container.

Have you thought about mapping it in a different directory on your hassio? You can edit the docker command in your service to add another bind mount and just point it somewhere else.

ok so maybe this is the thing.

I have HassIO installed on Debian and Debian is mounting the remote folder into
/usr/share/hassio/homeassistant/www/camera_save

I am not mounting the folder on HassIO.
I think I am not doing the right thing here and maybe the reason is the container is starting before the folder is mounted when debian boots?

I have no problem mounting somewhere else as long as then Homeassistant can write to the directory: how would you perform the task then?
Consider to me it is not clear what you mean with:

You can edit the docker command in your service to add another bind mount and just point it somewhere else.

in the meanwhile thank you very much for your support

I know.

Mount it to another directory that’s not in /usr/share/hassio

Edit your service file to add another bind mount.

You ran a script to install. Read the script. Figure out what the service file is and edit it.

Hi thanks again for this.

So I had a look to the script as you suggested but i can’t fully understand how to bind another mounting point.
As far as I understood this is where hass.io config is stored (code from install script)

echo “[Info] Install supervisor startup scripts”
curl -sL ${URL_BIN_HASSIO} > /usr/sbin/hassio-supervisor

and opening

/usr/sbin/hassio-supervisor

I see this

Load configs

CONFIG_FILE=/etc/hassio.json

SUPERVISOR=“$(jq --raw-output ‘.supervisor’ ${CONFIG_FILE})”

HOMEASSISTANT=“$(jq --raw-output ‘.homeassistant’ ${CONFIG_FILE})”

DATA=“$(jq --raw-output ‘.data // “/usr/share/hassio”’ ${CONFIG_FILE})”

and

/etc/hassio.json

shows

{
“supervisor”: “homeassistant/amd64-hassio-supervisor”,
“homeassistant”: “homeassistant/intel-nuc-homeassistant”,
“data”: “/usr/share/hassio”
}

which i understand i need to add another folder to be shared with hassio together with

“data”: “/usr/share/hassio”

now I absolutely have no idea how to proceed :frowning:
Browsed and searched the forum but with no luck: I am quite surprised no one went through this before :-/

I am sure i need to pass another folder here:

Init supervisor

HASSIO_DATA=${DATA}
HASSIO_IMAGE_ID=$(docker inspect --format=‘{{.Id}}’ ${SUPERVISOR})
HASSIO_CONTAINER_ID=$(docker inspect --format=‘{{.Image}}’ hassio_supervisor || echo “”)

runSupervisor() {
docker rm --force hassio_supervisor || true
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}
}

Run supervisor

mkdir -p ${HASSIO_DATA}
([ “${HASSIO_IMAGE_ID}” = “${HASSIO_CONTAINER_ID}” ] && docker start --attach hassio_supervisor) || runSupervisor

but really unsure how

Sorry for the delay. I had to reinstall everything because tight-vnc become my system into a login loop, what a disaster!

Now everything is ok, even the usb into Hassio

Thanks a lot!!!

@flamingm0e sorry to bother you again…I think I am very close to fix the issue, can you help last time?