![무선 설치로 전환 시 Samba를 설치할 수 없습니다.](https://linux55.com/image/23355/%EB%AC%B4%EC%84%A0%20%EC%84%A4%EC%B9%98%EB%A1%9C%20%EC%A0%84%ED%99%98%20%EC%8B%9C%20Samba%EB%A5%BC%20%EC%84%A4%EC%B9%98%ED%95%A0%20%EC%88%98%20%EC%97%86%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
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를 어떻게 마운트하나요? 이더넷을 통해서만 사용할 수 있는 일종의 캐시 스토리지 공유가 있습니까? 공유를 마운트 해제/마운트하려고 시도했지만 성공하지 못했습니다.
답변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