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 ubuntu home server 12.10 that is available over the internet for SSH connections. I also have my ubuntu laptop that I use at home and when on the road. What I would like is that during the boot, depending on the available WiFi connection, it either chooses cifs when on my home network, or SSHFS otherwise.

I don't want to use SSHFS by default on my home network as by going via dyndns and my limited home internet connection upload speed, I think it will be significantly slower for day to day tasks at home.

I don't think fstab has some sort of heirarchical mount tree that would allow me to do this (from what I have read in the man pages anyway).

Does this seem logical/reasonable, or am I going about it the wrong way? And if it is valid, how would I go about doing it?

Thanks in advance,



share|improve this question

Why not create a user-land script that runs when you log in? Try to do the cifs mount in /etc/fstab, if it fails do the sshfs when you log in.

Just add this to your login scripts:

mount | grep -q 'myhomeserver' || sshfs mydyndns /mountpoint
share|improve this answer

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.