[New Addon] Samba NAS. (Mount external disk and share it )

I don’t know.

1 Like

I have this error in my system log.

2021-01-25 22:16:24 ERROR (MainThread) [homeassistant.util.logging] Exception in message_received when handling msg on 'homeassistant/sensor/sambanas/state': '{"1":"1", "size_config":"230014904", "used_config":"13380528", "available_config":"204932308", "use_config":"6%", "size_addons":"230014904", "used_addons":"13380528", "available_addons":"204932308", "use_addons":"6%", "size_ssl":"230014904", "used_ssl":"13380528", "available_ssl":"204932308", "use_ssl":"6%", "size_share":"230014904", "used_share":"13380528", "available_share":"204932308", "use_share":"6%", "size_backup":"230014904", "used_backup":"13380528", "available_backup":"204932308", "use_backup":"6%", "size_media":"230014904", "used_media":"13380528", "available_media":"204932308", "use_media":"6%", "size_datadisk":"7751366040", "used_datadisk":"66617520", "available_datadisk":"7294030880", "use_datadisk":"1%"}'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 34, in wrapper
_log_message(msg)
File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 24, in _log_message
messages = debug_info["entities"][entity_id]["subscriptions"][
KeyError: 'sensor.sambanas_use_partition_2'

Any clue on how to fix this ?? (my log a flodded with this… like 25 times pr min.)

Maybe uninstall, and then use MQTT explorer to remove entities, and then reboot, and install again?

I would love to see this as an official add-on or the official one to expand to add this as an option.

It’s not quite as simple as that, in my experience.

1 Like

I’have already made the PR for the official add-on but was refused so I create this fork.

The use of smb/cifs share between add-ons is only a workaround solutions. The best solution will be a patch for operating system to allow mount arbitrary disk.
I started working on it but for multiple reasons the work has stopped for a long time.

2 Likes

That’s too bad. Seems like no-brainer

Unfortunately I don’t get how I can expose an external drive as time machine target. I disabled the protection mode and set everything I thought is necessary. The log says:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] automount.sh: executing... 
[08:47:04] INFO: Protection Mode is false
[08:47:04] WARNING: MoreDisk option found!
[08:47:04] INFO: More Disks mounting.. TimeMachine
[08:47:04] INFO: Mount TimeMachine
[08:47:04] INFO: Success!
[cont-init.d] automount.sh: exited 0.
[cont-init.d] mqtt.sh: executing... 
[cont-init.d] mqtt.sh: exited 0.
[cont-init.d] samba.sh: executing... 
[08:47:07] INFO: Hostname: homeassistant
tdbsam_open: Converting version 0.0 database to version 4.0.
tdbsam_convert_backup: updated /var/lib/samba/private/passdb.tdb file.
Added user TimeMachine.
[cont-init.d] samba.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
nmbd version 4.12.9 started.
Copyright Andrew Tridgell and the Samba Team 1992-2020
[08:47:08] INFO: Starting the MQTT daemon for disks info...
[08:47:08] INFO: Starting the AVAHI daemon for homeassistant...
daemon_ready: daemon 'nmbd' finished starting up and ready to serve connections
[services.d] done.
Waiting for daemon ...
smbd version 4.12.9 started.
Copyright Andrew Tridgell and the Samba Team 1992-2020
INFO: Profiling support unavailable in this build.
daemon_ready: daemon 'smbd' finished starting up and ready to serve connections
[08:47:09] INFO: Sending MQTT autodiscovery...
*****
Samba name server HOMEASSISTANT is now a local master browser for workgroup WORKGROUP on subnet 172.17.0.1
*****
*****
Samba name server HOMEASSISTANT is now a local master browser for workgroup WORKGROUP on subnet 172.30.32.1
*****
*****
Samba name server HOMEASSISTANT is now a local master browser for workgroup WORKGROUP on subnet 192.168.0.43
*****
Failed to fetch record!
pcap cache not loaded

The external drive was formatted on my Mac as MacOS journaled extended. Permissions for everyone set to Read and Write

The addon is started successfully. So you can mount your TimeMachine share as network disk from Windows, Linux ar MacOS.

I don’t understand your question or your problem. ;(

The problem is, that I can’t choose the TimeMachine Share unter System Preferences -> Time Machine -> Select Volume

it does not appear as available volume.

See the link below in the section ‘ If the share doesn’t appear…’

Hi @Lucio_Tarantino, since upgrading to Core 2021.2.3, the mount by labels stops with an error. I am using Home Assistant OS on Rpi3b+ 32 bits with OS 5.11.

I’ve double-checked the partition name with terminal and it is correct (Typing in portainerv “ls -l /dev/disk/by-label” shows: “NAS -> …/…/sda1”). However, I can mount the disk manually using /dev/sda1 in my own addon (which uses a custom apparmor.txt- not sure if this is relevant). In your own addon, “mount /dev/sda1 /zzz” results in “cannot mount /dev/sda1 read-only”

I wonder if this pull from the official addon could help : https://github.com/home-assistant/addons/pull/1825

BTW, thanks very much for this addon!

EDIT : I confirm that by adding a apparmor.txt such as this one to your addon, mounting is done properly https://raw.githubusercontent.com/alexbelgium/hassio-addons-1/master/sambanas/apparmor.txt

Here is the log:

[cont-init.d] automount.sh: executing... 
[22:01:40] INFO: Protection Mode is false
[22:01:41] WARNING: MoreDisk option found!
mount: /dev_: cannot mount devtmpfs read-only.
[22:01:43] WARNING: Unable to mount external drivers!
[cont-init.d] automount.sh: exited 0.

Supervisor log is OK:

21-02-19 22:00:22 WARNING (SyncWorker_1) [supervisor.docker.addon] Samba NAS running with disabled protected mode!
21-02-19 22:00:24 INFO (SyncWorker_1) [supervisor.docker.addon] Starting Docker add-on dianlight/armv7-addon-sambanas with version 9.3.0-nas6
21-02-19 22:00:51 INFO (MainThread) [supervisor.resolution.check] Starting system checks with state CoreState.RUNNING
21-02-19 22:00:51 INFO (MainThread) [supervisor.resolution.check] System checks complete
21-02-19 22:00:54 INFO (SyncWorker_6) [supervisor.docker.interface] Stopping addon_1a32f091_sambanas application
2 Likes

Hi @alexbelgium , can you give a little more detail how you solved it please?

Hi @mat2c, not sure to understand, do you mean that you still encounter the issue? Normally installing the latest addon version (v8) from the creator (Lucio_Tarantino) should solve the issue. It seems to me that a recent change in HA has modified the global apparmor profile applied by default to all profiles. Individual apparmor.txt files seems to be required to all proper functioning… That’s what the latest addon version includes (among other). If you want to learn more about apparmor their website has lots of info https://apparmor.net/

Hi @alexbelgium, thanks for answering!
That’s right, I still have the issue in version 8.
I changed apparmor.txt and restarted the service, but I still can’t start the addon:

[cont-init.d] automount.sh: executing... 
curl: (7) Couldn't connect to server
[11:57:40] ERROR: Something went wrong contacting the API
[11:57:40] INFO: Protection Mode is 
[11:57:40] WARNING: MoreDisk ignored because ADDON in Protected Mode!
[11:57:40] WARNING: A recommended add-on configuration option is not set.
[11:57:40] WARNING: The configuration key 'protected' seems to be empty.
[11:57:40] WARNING: Consider configuring this because:
[11:57:40] WARNING: moredisk only work when Protection mode is disabled

From journalctl:

feb 26 11:57:39 ha hassio-supervisor[1988]: 21-02-26 14:57:39 INFO (SyncWorker_2) [supervisor.docker.addon] Starting Docker add-on dianlight/amd64-addon-sambanas with version 9.3.0-nas8
feb 26 11:57:40 ha audit[1228485]: AVC apparmor="DENIED" operation="create" profile="1a32f091_sambanas" pid=1228485 comm="curl" family="inet" sock_type="stream" protocol=6 requested_mask="create" denied_mask="create"
feb 26 11:57:40 ha kernel: audit: type=1400 audit(1614351460.143:8012): apparmor="DENIED" operation="create" profile="1a32f091_sambanas" pid=1228485 comm="curl" family="inet" sock_type="stream" protocol=6 requested_mask="create" denied_mask="create"
feb 26 11:57:45 ha audit[1228668]: AVC apparmor="DENIED" operation="create" profile="1a32f091_sambanas" pid=1228668 comm="nmbd" family="inet" sock_type="dgram" protocol=0 requested_mask="create" denied_mask="create"
feb 26 11:57:45 ha kernel: audit: type=1400 audit(1614351465.035:8017): apparmor="DENIED" operation="create" profile="1a32f091_sambanas" pid=1228668 comm="nmbd" family="inet" sock_type="dgram" protocol=0 requested_mask="create" denied_mask="create"
feb 26 11:57:45 ha audit[1228756]: AVC apparmor="DENIED" operation="create" profile="1a32f091_sambanas" pid=1228756 comm="mosquitto_sub" family="inet" sock_type="dgram" protocol=17 requested_mask="create" denied_mask="create"
feb 26 11:57:45 ha kernel: audit: type=1400 audit(1614351465.455:8018): apparmor="DENIED" operation="create" profile="1a32f091_sambanas" pid=1228756 comm="mosquitto_sub" family="inet" sock_type="dgram" protocol=17 requested_mask="create" denied_mask="create"

Thanks,
Mat

This is not a problem with mount permission. The problem that the addon can’t connect to supervisor api.

Have you try a full reboot?

L.

Hi @Lucio_Tarantino!
Yes, I had. I also re-installed the addon.

supervisor:

21-02-26 17:04:13 INFO (MainThread) [supervisor.addons] Add-on '1a32f091_sambanas' successfully installed
21-02-26 17:04:20 WARNING (MainThread) [supervisor.api.addons] Changing protected flag for 1a32f091_sambanas!
21-02-26 17:05:23 WARNING (SyncWorker_0) [supervisor.docker.addon] Samba NAS running with disabled protected mode!
21-02-26 17:05:27 INFO (SyncWorker_0) [supervisor.docker.addon] Starting Docker add-on dianlight/amd64-addon-sambanas with version 9.3.0-nas8

addon log:

[cont-init.d] automount.sh: executing... 
curl: (7) Couldn't connect to server
[14:05:28] ERROR: Something went wrong contacting the API
[14:05:28] INFO: Protection Mode is 
[14:05:29] WARNING: MoreDisk ignored because ADDON in Protected Mode!
[14:05:29] WARNING: A recommended add-on configuration option is not set.
[14:05:29] WARNING: The configuration key 'protected' seems to be empty.

Thanks,
Mat

Can you post your addon config , host and supervisors version ?

Do you have other addons? Can you check their log for errors or warnings?

L.

Hi @Lucio_Tarantino:
config:

workgroup: xxxxx
username: xxxxx
password: xxxxx
interface: ''
allow_hosts:
  - 10.0.0.0/8
  - 172.16.0.0/12
  - 192.168.0.0/16
moredisks:
  - backups
veto_files:
  - ._*
  - .DS_Store
  - Thumbs.db
  - icon?
  - .Trashes
compatibility_mode: false
autodiscovery: {}

Core Version core-2021.2.3
Supervisor Version supervisor-2021.02.11 stable
Ubuntu 20.04.2 LTS
Docker version 20.10.3

Tnx,
Mat

So you are not on the ha operating system right?
If so you don’t need this addon. Config samba on your host is the better solution.