Page 1 of 1

Remote shares auto-mount

PostPosted: Wed Oct 30, 2013 9:11 am
by mdi
Hi guys,
I use a remote share as a backup destination. What would be the best way to mount it automatically after a NAS reboot?

Now, everytime that I have a power blackout or I reboot the nas, I have to remember to remount it manually, otherwise I get no backup.

Thanks,
MDI

Re: Remote shares auto-mount

PostPosted: Wed Oct 30, 2013 10:48 am
by Jocko
Now, everytime that I have a power blackout or I reboot the nas, I have to remember to remount it manually, otherwise I get no backup.

At least the last changes work well because previously,the files was saved to the data partition if the remote share was no longer available...:whistle

Otherwise, we could add an option to auto-mount these remote shares
Note play with fstab is not a good way because it's overwritten at each booting.

if you have linux acknowledge you can create a shell script which checks if the remote share are still mounting and if not it remounts it.
Then before your backup cron job add a new job to perform your shell.

Note:
to detect if a remote samba share is mounted:
Code: Select all
mount |grep -c '//remoteIP/remotesharename on /share/1000'
return 1 if is there. (of course replace remoteIP and remotesharename by the relevant value)
and for mounting a remote samba share
- clean a maybe orphan mount :
Code: Select all
umount /mnt/remote_share_mount_dir/remoteIP-smb-remotesharename
- and mount the share:
Code: Select all
mkdir -p -m 777 /mnt/remote_share_mount_dir/remoteIP-smb-emotesharename
mount -t cifs //remoteIP/remotesharename /mnt/remote_share_mount_dir/remoteIP-smb-emotesharename -o rw,iocharset=utf8,username=yourlogin,password=yourpasswd
mount -o bind /mnt/remote_share_mount_dir/remoteIP-smb-remotesharename /share/1000/remoteIP-smb-remotesharename


---edit---
attached a shell script type. you must replace each remoteIP, remotesharename, your login and your password by their relevant value.

Re: Remote shares auto-mount

PostPosted: Thu Oct 31, 2013 1:30 pm
by firwareslut
fstab seldom works correctly for auto mounting of network shares since it tries to mount them before the network is instigated.

You can try editing your cron command manually and putting

@reboot sleep 15; mount /mnt/remote_share_dir