Is it possible to remount a nfs share in HASS OS

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

i’m doing something similar.

  1. 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
  1. 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

First of all thank you so much for your time and answer :slight_smile:

So does this reconnect the mount I have added in hass and use for backups?

Why mkdir each time you run the command?

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 :wink:

Well, at least you know now, how to work with shell commands in an automation :wink:

Again your answers is much appreciated :slight_smile:
Yes its very useful I can send commands to my NUC now so thank you! :slight_smile:

1 Like

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.

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?

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?