Mount NAS on startup? - Exec Binding

Hello guys,

I want to mount my NAS via cifs automatically after reboot of the raspberry pi.
I am running openhabian on a rpi4.

This is my current approach:

rule"mounting test"

when

  System started

then

  logInfo("System Start", "Rule Systemstart executed ")

  executeCommandLine("mount -t cifs //192.168.1.200/Data/ -o username=admin,password=PASSWORD /etc/openhab2/mnt/nas")

  logInfo("System Start", "Mount command executed ")

end

But nothing gets mounted. What am I doing wrong ?

It might tell you…

val results = executeCommandLine("mount ...")
logInfo("System Start", "Mount command result: " + results)

2020-04-17 20:57:22.217 [INFO ] [.smarthome.model.script.System Start] - Mount command result: null

Still no idea how to make it work, since it doesn’t give me much information

Not much use,is it. Usually this is permissions problems.

Why would you want to do the actual mount in a rule? Makes more sense to just mount the share during the startup of the Pi.
Best,
E

It’s probably easier to use fstab to mount the share on boot instead of using an openHAB rule.

e.g.:

Just did exactly that. Works flawlessly.

Thank you guys for the quick help.

But it’s a bad idea to use CIFS to share a disk FROM a Linux (your NAS) TO another Linux (your openhabian box).
Use NFS instead.

How would the command need to look like?
Couldn’t get it working with NFS.
I have a QNAP nas.

Essentially use nfs in fstab instead of cifs, and don’t forget to enable and export (allow access) on your NAS. But that’s out of our scope here so please g**gle yourself.

2 Likes