[SOLVED] Automount of remote network share on startup

Hi,

to have majordomo statistics permanent, I have moved majordomo_db folder from /tmp to /mnt/majordomo_db.

/mnt/majordomo_db is mounted to my remote Synology NAS shared folder on my network via mount command

mount.cifs //192.168.2.10/majordomo_db /mnt/majordomo_db -o user=usr,password=pwd

So far so good. Now simple question, how to make that mount automatic after restart? I cannot find correct place where to put it.

Thanks.

Pavel

2 Likes

I will second this question–can anyone give some guidance on how to auto-mount in /etc/config/fstab?

I’ve looked at https://wiki.openwrt.org/doc/howto/cifs.client, but I’m not doing it right.

Any help appreciated!

–Chris

i already solved that. I put mount command to sh script file and put scheduling to majordomo configuration file for cron. Every 5 minutes it just call mount command, so it mounts, if its not mounted. Works.

Interesting solution, lol. I, myself, am looking into simply adding it to /etc/rc.local so when I boot up it will mount. Still have to test it out, but since I’m in a house full of folks, I think I’ll need to wait until night time before rebooting. Cheers!

I tried to solve it also already during starting process, but I have found out, at time of start, NAS is still not reachable through the network, therefore I cannot mount network folder, its just too early. Therefore I decided just to schedule it, its simple and works.

Another solution which works with latest updates is to create file (e.g. for NFS) /etc/hotplug.d/iface/99-nfs-mount
with content:

#!/bin/sh

. /lib/functions.sh

[ "$DEVICE" == "lo" ] && exit 0

case "$ACTION" in
  ifup)
    if [ "$DEVICE" == "br-lan" ]; then
      mount -t nfs cloudia.lan:/nfs/Public /mnt/cloud/public -o nfsvers=3 -o nolock
    fi
    ;;
  ifdown)
    if [ "$DEVICE" == "br-lan" ]; then 
      umount  /mnt/cloud/public
    fi
    ;;
esac
1 Like