Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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.

share|improve this answer
    
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
show 2 more comments

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
share|improve this answer
    
+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 Oct 9 '12 at 22:11
add comment

Your Answer

 
discard

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.