SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-11-07 03:15:17

nathwill
#! CrunchBanger
From: Portland, OR USA
Registered: 2010-11-05
Posts: 215
Website

Automated Remote FileSystem Mount over NFS/SSHFS

Hi folks, not quite my first post here, but close, so forgive me if I miss something that should be included...

I have a little QNAP TS-110 at home that I use as a backup server/media server/seedbox/print server and I got tired of manually mounting the share, so i figured I'd share the solution I came up with, as it's been really nice to always have access to my larger drive when I'm away from home.

The script is pretty simple, it just does a quick check for the router (gateway) MAC address, and if it's the MAC address of your home router it mounts the drive over NFS (could work for SMB or whatever else, though you'd have to modify /etc/fstab). If my home router's mac is not found as the gateway mac, the script defaults to mounting the drive over sshfs.

first

#!/bin/bash
#make script executable at /etc/NetworkManager/dispatcher.d/50-mount-remote
#customize below for your setup
gateway=`ip route show 0.0.0.0/0 | awk ‘{print $3}’`
mactest=$(arp -n -a $gateway | awk ‘{print $4}’)
targetmac="00:00:00:00:00:00"
homeupcommand="mount /home/nathan/remote"
homedowncommand="umount /home/nathan/remote"
awayupcommand="cd /home/nathan && sudo -u nathan sshfs nathan@your.dyndns.com:/home/nathan /home/nathan/remote"
awaydowncommand="cd /home/nathan && sudo -u nathan fusermount -u /home/nathan/remote"
#
# should not need to modify below here unless you know what you are doing
#
if [ $mactest==$targetmac ]
then
        case "$2" in
                up)
                        $homeupcommand
                ;;
                down)
                        $homedowncommand
                ;;
        esac
else
    case "$2" in
        up)
            $awayupcommand
        ;;
        down)
            $awaydowncommand
        ;;
    esac
fi
exit $?

and the /etc/fstab entry... (the noauto mount option is the important part)

homenet:/home/nathan    /home/nathan/remote    nfs    noauto,rw,rsize=8192,wsize=8192,timeo=14,intr    0    0

*note: this does depend on the use of NetworkManager, though the task could still be reworked for ifup/ifdown use instead

enjoy! within a few seconds of establishing a network connection, you should have remote access to your server/share drive!

Last edited by nathwill (2010-11-07 03:40:42)


NOTICE: alloc: /dev/null: filesystem full

Offline

Help fund CrunchBang, donate to the project!

#2 2012-10-16 18:58:21

plc613
New Member
Registered: 2012-10-16
Posts: 2

Re: Automated Remote FileSystem Mount over NFS/SSHFS

I realize the post is quite old but I was just curious as to what steps you took to get your QNAP to allow normal users to ssh in?

Offline

#3 2012-10-17 00:43:10

pidsley
Window Mangler
Registered: 2012-05-23
Posts: 1,752

Re: Automated Remote FileSystem Mount over NFS/SSHFS

The OP hasn't posted here since February 2012, so you might have more luck sending him an email, or trying his web site (it's in his profile): http://crunchbanglinux.org/forums/user/7304/

Or post your question with more details in a separate topic, where others may be able to help you.

And BTW, welcome to #!

Offline

#4 2012-10-17 05:12:49

nathwill
#! CrunchBanger
From: Portland, OR USA
Registered: 2010-11-05
Posts: 215
Website

Re: Automated Remote FileSystem Mount over NFS/SSHFS

i'm here! tongue i flashed debian onto my qnap as described on this site (select the appropriate model)

http://www.cyrius.com/debian/

once you have debian installed, the rest is easy smile


NOTICE: alloc: /dev/null: filesystem full

Offline

#5 2012-12-06 03:32:21

plc613
New Member
Registered: 2012-10-16
Posts: 2

Re: Automated Remote FileSystem Mount over NFS/SSHFS

nathwill wrote:

i'm here! tongue i flashed debian onto my qnap as described on this site (select the appropriate model)

http://www.cyrius.com/debian/

once you have debian installed, the rest is easy smile

Yes, of course.

Thanks for the reply. I managed to find another post that didn't involve too many changes.

P.S> Debian is the best wink

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo