Before you say "no", a workaround would also be fine.

Here is the situation: I have two machines local and compile, both including the same ~ over nfs from a third machine files. I would like to have a directory on compile:/opt/foo/ instead of files:~/foo/ for speed. But I want to still be able to work from local without having to work on a different path.

I can sshfs mount compile:/opt/foo/ locally on local:~/compile/opt/foo/ but if I want to have one directory at the same path inside my ~ on both machines, symlinks don't seem to cut it, as they want to point at the same path.

Is there a solution for this problem that enables me to have my files sitting on the local drive of compile instead of the nfs mount?

Note: I cannot gain root privileges on any of these machines.


You will need to do a double symlink similar to what /etc/alternatives does on Ubuntu namely:

Inside ~ you will have a link:

linked_directory -> /<local filesystem>/linked_directory

On each of the local machines:

/<local filesystem>/linked_directory -> /<actual location>/linked_directory

As long as neither /<local filesystem>/ nor /<actual location>/ are shared between machines inside your ~ the contents of linked_directory will be unique.

  • I think he has no root privileges, which means he cannot step outside of his home directory (a link in /tmp would be problematic). – January Oct 9 '12 at 13:32
  • @January There is also /var/tmp and possibly other local directories OP has access to. Besides someone did set up /opt/foo as a mountpoint for the OP(cringe), which does require root privileges. – Karlson Oct 9 '12 at 13:37
  • Well, sure, if the administrator does that, that would definitely be the easiest solution! – January Oct 9 '12 at 14:46
  • @Karlson: Actually it's compile:/opt/<username>/. Why is that cringe-worthy? – bitmask Oct 9 '12 at 15:18
  • @bitmask Because generally /opt is meant for optional software installation not user's home directories. A better practice is to have software developed, tested, in /home/<user> and once the software is done you make it read only and put in /opt/ or /usr/local, so that people don't have an option to fat-finger things – Karlson Oct 9 '12 at 16:13

Symlinks will not help, since they are written to the filesystem -- and so they will always be the same on both machines.

However, if your administrator installed bindfs, you can mount different things on both machines. For example, on local, you use sshfs to mount compile:/opt/foo/ with ~/foo/ as the mount point. On compile, you use bindfs to mount /opt/foo/ with ~/foo/ as your mount point:

bindfs -n /opt/foo ~/foo
  • +1 for the suggestion, but compile doesn't seem to have bindfs installed. – bitmask Oct 9 '12 at 15:16
  • @bitmask If you have SSHFS, you have FUSE. Enabling FUSE requires privileges, but installing additional filesystems such as Bindfs doesn't, you can do it. – Gilles 'SO- stop being evil' Oct 9 '12 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.