Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a notebook with Scientific Linux 6.1. I have a wireless router with OpenWrt 10.03 - Wrt160NL. I have a HDD on the router that I share via samba:

cat /etc/samba/smb.conf.template
workgroup = workgroup
guest account = nobody
security = share
browseable = yes
guest ok = yes
guest only = no
log level = 2
log file = /tmp/log/smbd.log
max log size = 100
encrypt passwords = yes
dns proxy = no
host allow =
netbios name = Router
server string = Linksys WRT160NL Router
socket options = TCP_NODELAY
client code page = 852
dos charset = 852
unix charset = UTF-8
display charset = UTF-8
character set = ISO8859-2

comment = SHARE
path = /mnt/hdd/PUB
browseable = yes
public = yes
guest ok = yes
writable = no

and on client side:

cat /etc/fstab
// /home/USERNAME/Desktop/SHARE cifs ro,noexec,nosuid,nodev,noatime,password=,nolock 0 0


  • When someone is connecting to the router via ethernet cable then it could see the share on the router.
  • When someone is connecting to the router via wireless then it could see the share on the router.

BUT -> the problem -> when someone is using the ethernet cable, and plugs it out, and switches to wireless the share dissapears, and it can't mount it:

mount -vvv // /home/USERNAME/Desktop/SHARE -o ro,noexec,nosuid,nodev,noatime,password=,nolock -t cifs

because the command times out. But if we plug back the ethernet cable and go in to the "SHARE" directory under GNOME2 it automatically mounts.

QUESTION: how can I mount the SHARE after switching to wireless? (are there some kind of cache that stores that the SHARE is only available via the ethernet? - I tried to umount/mount the SHARE but it didn't worked. )

share|improve this question
Looks more like routing problem. netstat -rnA inet, do you see your router accessible via "old" connection? – Jiri Xichtkniha Jun 17 '12 at 19:58
up vote 2 down vote accepted

I solved it with a bash script.. (in short it uses rmmod cifs/modprobe cifs - after this I could mount the share without the timeout..ü)


which timeout > /dev/null 2>&1; if [[ $? -ne 0 ]]; then echo -e '\nerror, no coreutils package'; exit 1; fi
which nc > /dev/null 2>&1; if [[ $? -ne 0 ]]; then echo -e '\nerror, no nc package'; exit 1; fi

# variables

# functions
function notthesame()
    # umount PATHTOIT
        while `mount | grep -qi $PATHTOIT`; do timeout -s 9 2 umount -l $PATHTOIT; done
        timeout -s 9 2 pkill -9 -f "SHARE"
        timeout -s 9 2 pkill -9 -f "umount -a -t cifs"
        timeout -s 9 2 pkill -9 -f "/sbin/mount.cifs"
        timeout -s 9 2 pkill -9 -f "rmmod -fw cifs"
        timeout -s 9 2 pkill -9 -f "/sbin/modprobe -q -- cifs"
        timeout -s 9 2 pkill nautilus

    # remove/add cifs kernel module
        timeout -s 9 2 rmmod -fw cifs
        timeout -s 9 2 modprobe cifs

    # mount PATHTOIT
        timeout -s 9 2 mount $PATHTOIT

while true; do

    # wait until we can reach the samba server
        while true; do nc -w 1 139 >& /dev/null && break && sleep 10; done

    # first sample
        REGIINTERF=`netstat -nr | awk '/0/ {print $NF}' | sort -u`

    # sleep 10
        sleep 10

    # second sample
        MILYENINTERFMOST=`netstat -nr | awk '/0/ {print $NF}' | sort -u`

    # compare the samples
        [ "${MILYENINTERFMOST}" = "${REGIINTERF}" ] || notthesame

    # if can't find mountpoint then mount it
        if ! mount | grep -qi $PATHTOIT; then notthesame; fi

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.