Thrawn
November 22, 2024, 6:14pm
1
I have a nas that shuts down doing the night. my HASS running on a RP4 is up 24/7 so if cause it loses connection to my NAS share at night.
Is it possible to run an automation, maybe with SSH command, that remounts my nfs when Uptime Kuma tells me HASS NAS is up?
Thank you all in advance
/Thrawn
BebeMischa
(Bebe Mischa)
November 22, 2024, 6:58pm
2
i’m doing something similar.
define your shell commands in configuration.yaml (be aware, correct shell command depends on your situation)
# Mount NAS drives
shell_command:
mount_nas_music: mkdir -p /media/NAS/Music;mount -t cifs -o username=xxxxxx,password=xxxxxx,domain=xxxxxx //xxx.xxx.xxx.xxx/Music/Musicaudio /media/NAS/Music
mount_nas_movies: mkdir -p /media/NAS/Movies;mount -t cifs -o username=xxxxxx,password=xxxxxx,domain=xxxxxx //xxx.xxx.xxx.xxx/Movies/Movies /media/NAS/Movies
mount_nas_musicmovie: mkdir -p /media/NAS/Musicmovie;mount -t cifs -o username=xxxxxx,password=xxxxxx,domain=xxxxxx //xxx.xxx.xxx.xxx/Music/Musicmovie /media/NAS/Musicmovie
automate (change your trigger to anything you like…)
alias: Mount NAS on start
description: ""
mode: single
triggers:
- event: start
trigger: homeassistant
conditions: []
actions:
- delay:
hours: 0
minutes: 3
seconds: 20
milliseconds: 0
- data: {}
action: shell_command.mount_nas_music
- data: {}
action: shell_command.mount_nas_movies
- data: {}
action: shell_command.mount_nas_musicmovie
Thrawn
November 22, 2024, 9:31pm
3
First of all thank you so much for your time and answer
So does this reconnect the mount I have added in hass and use for backups?
Why mkdir each time you run the command?
BebeMischa
(Bebe Mischa)
November 22, 2024, 9:43pm
4
No, it will not do that.
It makes it’s own mounts. This is created by Mostlychris years ago, before it even was possible to mount anything from the UI.
I’m not changing it, because it works all those years reliably.
Maybe there is a possibility to write a shell command to reconnect instead of mount, but that’s above my knowledge
Well, at least you know now, how to work with shell commands in an automation
Thrawn
November 22, 2024, 9:44pm
5
Again your answers is much appreciated
Yes its very useful I can send commands to my NUC now so thank you!
1 Like
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
November 22, 2024, 10:44pm
6
Just know that this is not supported. Also if you do not exclude those paths from your backup, it is likely that you have more data than your main drive can handle, and the backup will fill up your OS and crash everything. I have done this twice.
There is no supported way to connect a second drive directly. You need to consider one of the supported methods.
Mounting drives can VERY much break your system. If the drive mounted brings the backup size bigger than available, for instance, the HA drive will fill up and the system will crash. If you plug in a memory stick, for instance, with malware, that would cause all kinds of problems.
Plus if you really want a drive mounted, install core or another install method where you are in control of the OS.
Thrawn
November 23, 2024, 2:43pm
7
So you are saying that the only way to reload the network share used for backup in an automation is restarting hass when nas is up?
BebeMischa
(Bebe Mischa)
November 23, 2024, 2:49pm
8
I’ve never excluded anything from backups. The paths, I’ve mounted are 7 TB of files worth.
My backups are are 8GB consistently.
So, maybe, the Mostlychris method will automatically ignored from backup?