Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 laptop and NAS. What I want to do is to mount my NAS only when my wireless is connected, and umount it at wireless disconnected.

I have written both scripts I wat to run- they check the name of the connection and connect or disconnect. I have added the connect and disconnect scripts to to /etc/network/if-up.d and /etc/network/if-down.d.

The script which starts at if-up works correctly, the other one not- it will simply not umount. I thing the script executes when the wireless is already disconnected.

I want a way to run the script pre-disconnecting the wireless.

I used to do this with wicd in Kubuntu 11.04, but it seems too buggy now.

share|improve this question

Of course you understand that your system can't figure out when will a wireless connection drop unless you press a button that tells it.

From what I have seen you just want to get rid of the mount when the network goes down, for that you can use

umount -l /mnt/folder

Its considered dangerous by many since it will unmount a file system that might still be in use but since your network is already down I don't see much of a problem.

share|improve this answer
I try to run umount -l /media/MyBookLive Unfortunately, the command will not work as expected - the system will still hang waiting for the NAS to respond... I will have to swallow wicd bugs probably – deckoff Oct 24 '11 at 15:20

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.