[SOLVED] HASSOS mount NAS network share

Tutorial for HASSOS on PROXMOX, network share and Frigate

-----------------------Deprecated:---------------------------
I have sucessfuly mounted network share to HASSOS on PROXMOX.
I would like to share it with you, feel free to give like or comment :slight_smile:

!!!Before starting, make BACKUP!!!

1.Story
2.Making the changes to HASSOS
3.Check NAS availability
4.Automate it with PROXMOX ISO boot
5.What if?
6.Please vote for FR!!!

1.Story
Why?
The HASSOS frigate addon is perfect but doesnt have / or i didn’t find the option to mount network share inside for all addons.

Problems on the way?
Hell yeah, when i mounted HASSOS from a linux mint cd image a found out its not regular ext file system, its squashfs.
And its read only :open_mouth: never heard about it before.And started to poke.
So i am making this toturial so you can mount your network share for media to be used in HASSOS for the whole system included addons.

Trying different ways?
I was trying to make a seperate container for Frigate
https://community.home-assistant.io/t/network-share-on-frigate-hassos-with-nabucasa-ssl-and-proxmox-lxc-container/
But it did’nt went well,because i cant use iframe for the frigate integration through nabucasa

What experience you should have to proceed?
-Understand how to boot live cd on HASSOS system
-Understand shell commands and logic
-Ready to copy / paste :slight_smile:

I am not using any coral, for that you need assistance from somebody else afterwards :>
I’m using integrated INTEL graphics

Frigate thread:

https://community.home-assistant.io/t/local-realtime-person-detection-for-rtsp-cameras/

2.Making the changes to HASSOS
Soooo where to begin.
First you need to download linux mint iso (or any other,i like this one,its user friendly)

https://www.linuxmint.com/download.php

or as a alternative you can try mounting on another VM like @srk23 suggested:

If you still want to do live boot cd:
Then you need to mount it,boot from it (don’t install anything)
Open terminal

cd /mnt
lsblk

or

fdisk -l

You sould see list of available disks/partitions
They should be sda1-sda8
So the HASSOS root files are in sda3 and sda5(they are identical, i just didn’t botherd and change on both)
The partitions are so called squashfs not regular ext or ntfs/fat
now we will extract files from the partition

sudo unsquashfs -i /dev/sda3

New file was created under mnt/squashfs-root
now

nano /mnt/squashfs-root/etc/fstab

Add neccesery lines

//<NASIP>/<NASSHARE>  /mnt/data/supervisor/media  cifs  nofail,username=<SMBUSER>,password=<SMBPASS>,iocharset=utf8,x-systemd.after=network-online.target  0  0

save close

cd /mnt

convert folder to squashfs and copy it to device partition

sudo mksquashfs squashfs-root/ squash.rootfs.1
sudo dd if=./squash.rootfs.1 of=/dev/sda3

After finish

rm -r /mnt/squashfs-root
rm /mnt/squash.rootfs.1

And do the same for /dev/sda5

sudo unsquashfs -i /dev/sda5

New file was created under mnt/squashfs-root
now

nano /mnt/squashfs-root/etc/fstab

Add neccesery lines

//<NASIP>/<NASSHARE>  /mnt/data/supervisor/media  cifs  nofail,username=<SMBUSER>,password=<SMBPASS>,iocharset=utf8,x-systemd.after=network-online.target  0  0

save close

cd /mnt
sudo mksquashfs squashfs-root/ squash.rootfs.1
sudo dd if=./squash.rootfs.1 of=/dev/sda5

After finish

sudo shutdown now

Remove CD from boot
Start HASSOS and you can login to HOST device and check if its mounted under
/mnt/data/supervisor/media
check

dmesg | grep cifs

or

dmesg | grep mount

or

ls -la /mnt/data/supervisor/media/*

You maybe need to add vers=1.0 for the fstab mount idk your specifics

3.Check NAS availability
Make a file in the network folder called “thisisnas”
and just edit it and put

on

That’s it
Next,
Add this to binary_sensors.yaml (thank you to @srk23 )

- platform: command_line
  name: NAS Mount
  command: "[ -f /media/thisisnas ] && echo 'on' || echo 'off'"
  payload_on: "on"
  payload_off: "off"

And you can make some notification when the NAS is offline.
From up to down.

When NAS comes from offline to online,
it is neccasary to restart the HASSOS as follows (otherwise the sensor is not going to online state idk why)
Supervisor → System → reboot host

Then you can install the Frigate NVR addon
Dont forget to seperate the frigate.db from nas
frigate.yml

database:
  path: /config/frigate.db

4.Automate it with PROXMOX ISO boot
Read docs

md5 checksum is
d8f187a8a8804cf0f71951d4b48cc77e

5.What if?
If the network share is down, you will see this text on the host display:

host is down or BAD NETWORK NAME

And this in Supervisor LOGS:

21-04-27 14:17:01 ERROR (SyncWorker_1) [supervisor.docker] Can't start addon_a0d7b954_ssh: 500 Server Error for http+docker://localhost/v1.40/containers/e2f1a348e9e94f9f37f3e2860e3a202d5a5cdce348ee893849a8ac460a390e78/start: Internal Server Error ("error while creating mount source path '/mnt/data/supervisor/media': mkdir /mnt/data/supervisor/media: file exists")

And you cant start any addons that are mount to media network share.
Just restart fully and it should work

6.Please vote for FR!!!

Sources:

google.com
https://magazine.odroid.com/article/using-squashfs-as-a-read-only-root-file-system/

9 Likes

Excellent! I have been trying for days to mount a samba share on homeassistant OS, this did the trick. Now I can make available some decently sized disk for the recordings.

I used a slightly different method since I am running homeassistant OS on a proxmox VM.
I created another VM and mounted the homeassistant disk as secondary. This way all partitions show up as /dev/sdb1-/dev/sdb8. The rest is the same.

1 Like

Noice!!! I am very happy that i helped :slight_smile:
I was trying for over a week, with differents methods that didn’t work and then i just gave up.
After some time i was following the trail of the media folder where it ends and i was like ,wait i need the host machine and that’s it :smiley:

Will this be persistant? In other words will it survive any upgrades?

1 Like

I think yes, but there is a possibility that will not, as there are 2 same partitions. One of it might be as a backup or as a temperary system before new upgrade.
Lets wait and see. If it will be a problem i will just make a script and automate it :laughing:
Let me know if you upgrade sooner and will be having problem neverthe-less if you make the switch with notification,you will be notified :slight_smile:

Okay so i have another HASS instance, core was not updated i will now test it if its persistant :slight_smile:
-------- UPDATE 1
Interesting i have another HASS and so when its showing that core update is available sda5 does not have a partition type :open_mouth: my mind just blew :))) So i changed on sda3 and it mounted fine. Now i will perform core update and see :slight_smile:
-------- UPDATE 2
So as it was only on sda3 i updated the operating system and then the mount stopped working.
When i check the sda3 the file is still there, so i think sda3 is for backup and sda5 is the operating system that have priority.After operating system update it was possible to edit on sda5.And it starting to mount again. Now i will try update core and see.
-------- UPDATE 3
After CORE update, it mounted successfully :slight_smile: So i’m prety sure it will survive any next update. So i think when you have update waiting it just block the sda5 and prepare for update. Will try again when new operating system update will be available (soon) :slight_smile:

Thank you so much for this - I’ve been trying to do this for months! All working for me following your instructions.

As per @robha I am using a Proxmox VM. I have a few other VMs running Ubuntu, so I mounted the HA disk inside one of them rather than using a live CD. For anyone else trying this, you will need to manually edit the configuration for the linux VM that you are going to use, and insert the HA disk (e.g. local-lvm:vm-100-disk-1) as a secondary drive. Make sure that you stop the HA VM first, and remove this disk from the second VM before restarting HA!

I have a preference for using a command line binary sensor rather than a switch for monitoring (a bit cleaner):

- platform: command_line
  name: NAS Mount
  command: "[ -f /media/nasup ] && echo 'Up' || echo 'Down'"
  payload_on: "Up"
  payload_off: "Down"

This simply checks whether a file on the NAS is accessible and sets the sensor to on and off. Can be used in the automation in the same way as the switch.

1 Like

Thank you for comment :))) happy to help.
Thank you for the binary sensor, your solution is better, i put it in my post with a reference :slight_smile:

I’m guessing this change won’t survive a Home Assistant OS update, right?

It definetly survived the core update. It should survive OS also,but i can only confirm when i try.

Yes - seems to be fine after updates.

2 Likes

noice! thx for info

Unfortunately after the update to ver 6 i needed to edit fstab on sda3 again. sda5 was fine. It took me like 5 minutes. So i think its fine to do it once a month. Next time i will make script for that to make it one time thing.Or maybe even better make my own bootable image to modify the partitions

Urgh. Just realised that mine hasn’t been mounted since I updated. Took me considerably longer than 5 minutes to get it back up and running again!

i see, next update i will be doing my own iso image, that you can mount and boot,then it will just run the script and update the sda3 sda5 automaticaly. There will be a promnt.Or maybe i can read from config folder and you could save the variables there ? :slight_smile:
The solution is only matter of time :stuck_out_tongue:

So i found gparted iso image which is like 400MB, what do you think put the script hardcoded to image and read variables like ips password from file in config folder in hass?
or run the script that will be saved in config hass folder? Then anybody can change the script on whatever he wants?
I will be making tutorial on how anybody can create his own iso image if will not be comfortable to use mine

UPDATE:
Nevermind, easier would be to make the whole script inside the HASS config.

You didn’t make notification with the binary sensor? :smiley: i did :stuck_out_tongue: so it notify me when nas is offline

Oops tuns out I have been recording for a while to my root filesystem instead of the network share. Better keep track of this in the future.

1 Like

make the binary sensor man as per instruction, its the easiest way. Don’t start frigate automaticaly, i always start manualy in supervisor. This need to be tested more :>

I do, but it didn’t fire. I think it might be a poorly coded automation - it fires when the sensor changes from on to off, but as the connection is lost on restart after an upgrade, there is no state change…

A lightweight vm/iso with a shell script that unpacks and mounts the filesystem, uploads the alternative fstab and repacks it would do the trick I think… Unless there is a way to edit the fstab directly from HA without needing to mount the image? But presumably not as the filesystem is read only… Might be more tricky to get it working with my setup in Proxmox than yours I think…