Ich habe ein Notebook mit Scientific Linux 6.1. Ich habe einen WLAN-Router mit OpenWrt 10.03 - Wrt160NL. Ich habe eine Festplatte auf dem Router, die ich über Samba freigebe:
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
und auf der Clientseite:
cat /etc/fstab
//192.168.1.1/SHARE /home/USERNAME/Desktop/SHARE cifs ro,noexec,nosuid,nodev,noatime,password=,nolock 0 0
Das FUNKTIONIERT SUPER!
- Wenn jemand über ein Ethernet-Kabel eine Verbindung zum Router herstellt, kann er die Freigabe auf dem Router sehen.
- Wenn sich jemand drahtlos mit dem Router verbindet, kann er die Freigabe auf dem Router sehen.
Das Problem tritt auf, wenn jemand das Ethernet-Kabel verwendet, es dann abzieht und auf drahtlose Verbindung umstellt: Die Freigabe verschwindet und kann nicht gemountet werden:
mount -vvv //192.168.1.1/SHARE /home/USERNAME/Desktop/SHARE -o ro,noexec,nosuid,nodev,noatime,password=,nolock -t cifs
weil der Befehl abläuft. Aber wenn wir das Ethernet-Kabel wieder einstecken und in das Verzeichnis „SHARE“ unter GNOME2 gehen, wird es automatisch gemountet.
Wie kann ich den SHARE mounten, nachdem ich auf Wireless umgestellt habe? Gibt es eine Art Cache, der speichert, dass der SHARE nur über Ethernet erreichbar ist? Ich habe versucht, den SHARE zu umounten/mounten, aber das hat nicht funktioniert.
Antwort1
Ich habe es mit einem Bash-Skript gelöst. (kurz gesagt, es verwendet rmmod cifs/modprobe cifs – danach konnte ich die Freigabe ohne Timeout mounten..ü)
#!/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