I have had big problems with CIFS mounts hanging when I reboot or halt my Linux laptop.
It seems that NetworkManager shuts down the interface too soon and thus the mount is left open.
To fix this, I disabled NetworkManager and configured my WLAN interface through the interfaces file.

.

Disable NetworkManager:

# stop network-manager
# echo manual > /etc/init/network-manager.override

Configuring static IP for your WLAN interface adds a boot up delay from /etc/init/failsafe.conf.
Disable the delays by commenting out these lines:

    # The point here is to wait for 2 minutes before forcibly booting 
    # the system. Anything that is in an "or" condition with 'started 
    # failsafe' in rc-sysinit deserves consideration for mentioning in
    # these messages. currently only static-network-up counts for that.

        #sleep 20

    # Plymouth errors should not stop the script because we *must* reach
    # the end of this script to avoid letting the system spin forever
    # waiting on it to start.
        #$PLYMOUTH message --text="Waiting for network configuration..." || :
        #sleep 40

        #$PLYMOUTH message --text="Waiting up to 60 more seconds for network configuration..." || :
        #sleep 59
        #$PLYMOUTH message --text="Booting system without full network configuration..." || :

Create the WLAN configuration file /etc/wpa_supplicant/wpa_supplicant.conf:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=root
update_config=0

network={
    ssid="ssid"
    psk=psk
    proto=WPA2
    key_mgmt=WPA-PSK
    pairwise=CCMP
    auth_alg=OPEN
}

The psk can be created with $ wpa_passphrase ssid.

Create /etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)                                                             
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto wlan0

# ---------------------------------------

iface wlan0 inet static
    address 192.168.1.8
    netmask 255.255.255.0
    gateway 192.168.1.1

... or ...

iface wlan0 inet dhcp

# ---------------------------------------

    pre-up /sbin/wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -D wext
    post-up /usr/bin/pgrep wpa_supplicant > /var/run/sendsigs.omit.d/wpa_supplicant.pid
    post-down killall -q wpa_supplicant
    dns-nameservers dns_server_1 dns_server_2

Activate the wlan0 interface:

# ifup wlan0

If you get the error message ioctl[SIOCSIWENCODEEXT]: Invalid argument,
remove -D wext from /etc/network/interfaces or replace it with another driver variant from
$ wpa_supplicant -h.

Advertisements