I wanted to tell you about my discovery afuse - automatic mounting of file systems on demand, automatically. Isn't it great just to do:
ls /mnt/remote/web.example.com/var/lib/www/
And immediately see the files of the web-server, without in any way establishing a connection with it specifically? I use it for a long time, and most importantly:
What is it and why
It can be used with different systems, but the most convenient course with
sshfs . I think many have dealt with it, it is really convenient, but if you need to walk around a remote file system, you have to mount it every time:
sshfs hostname: mountpoint
It becomes extremely tedious when you work with hundreds of remote servers, especially when you need it, for example, to quickly transfer a small config file from one remote server to another (and it’s better not to download large files via sshfs and rsync or bbcp) .
Afuse open source project is itself a fuse file system. It is available for most modern distributions.
Very good article about its description, and also setup was already on Habré . All those who try it for the first time, send it there.
We, not to repeat, go a little further.The only thing I would like to note is that for distributions based on RPM (Fedora, CentOS, RHEL, Scientific Linux ...) you will need to use yum / dnf:
dnf install afuse
Use yum instead of dnf on older systems such as CentOS.
Setting the keys, hosts and mount options is unlikely to be very different, for subtleties you can always refer to the manual.
Afuse automount
I believe that you have already played and you liked mounting sshfs on the fly. Here is only in the above article, well, very crooked way to mount afuse itself. I suppose that you, too, have a sediment:
“How is it that the file system that mounts other file systems needs to be manually mounted each time !?”Exactly how to do this and I wanted to share.
In fact, all the mechanisms are already in the system. So, since afuse itself is a file system, then why not mount it in the standard way from / etc / fstab !?
In principle, this is very possible, but there is no direct way to pass so many desired arguments.
Therefore, it is supposed to create a wrapper script /usr/sbin/mount.afuse (laid out as well as the
gist is more convenient for someone, there is also a more detailed description of it) of approximately the following content:
Do not forget to make it executable:
chmod +x /usr/sbin/mount.afuse
Now we are ready to add a new system mount point in / etc / fstab:
afuse# /mnt/remote afuse auto 0 0
Everything, from this point on, even after rebooting the system, afuse is mounted, and all connections to remote hosts will be restored automatically if some programs worked with remote files along such paths. There will be no errors that something is not available.
Of course, you can change the mount point at will, maybe something like / remote. Do not forget to just create a directory.
Update 02/14/2017: According to the
Self_Perfection comment, the
helper code has
been slightly improved to get the user, from which the directory will be mounted. It has become more simple and understandable.