무선으로 전환할 때 Samba 마운트가 마운트되지 않습니다

무선으로 전환할 때 Samba 마운트가 마운트되지 않습니다

Scientific Linux 6.1이 설치된 노트북이 있습니다. OpenWrt 10.03 - Wrt160NL이 설치된 무선 라우터가 있습니다. 삼바를 통해 공유하는 라우터에 HDD가 있습니다.

cat /etc/samba/smb.conf.template
[global]
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 = 192.168.1.0/24
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

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

그리고 클라이언트 측에서는:

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

이것은 훌륭하게 작동합니다!

  • 누군가 이더넷 케이블을 통해 라우터에 연결하면 라우터의 공유를 볼 수 있습니다.
  • 누군가 무선을 통해 라우터에 연결하면 라우터의 공유를 볼 수 있습니다.

문제는 누군가 이더넷 케이블을 사용하고 있다가 케이블을 뽑고 무선으로 전환할 때 발생합니다. 공유가 사라지고 마운트할 수 없습니다.

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

명령 시간이 초과되었기 때문입니다. 그러나 이더넷 케이블을 다시 연결하고 GNOME2 아래의 "SHARE" 디렉터리로 이동하면 자동으로 마운트됩니다.

무선으로 전환한 후 SHARE를 어떻게 마운트할 수 있나요? SHARE가 이더넷을 통해서만 사용 가능하다는 것을 저장하는 일종의 캐시가 있습니까? SHARE를 마운트 해제/마운트하려고 했지만 작동하지 않았습니다.

답변1

bash 스크립트로 해결했습니다.. (간단히 말하면 rmmod cifs/modprobe cifs를 사용합니다. 이후에는 시간 초과 없이 공유를 마운트할 수 있습니다..ü)

#!/bin/bash

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
    PATHTOIT="//192.168.1.1/SHARE"

# 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 192.168.1.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

done

관련 정보