As I have said previously, I really like the automounter, and feel It my geeky duty to push my luck with what can be done with it.
When in the office we have a standard automounter mount point /share/install which allows access to all the install images of all the software that we have. Now when at home I wanted the same thing but to get the data from the office over ADSL. But then ssh will do compression which I have found can significantly improve access times. Could I tunnel NFS over ssh and still get the automounter to do it’s stuff?
First you have to tunnel the NFS tcp port over ssh:
ssh -C -L 6049:nfs-server:2049 myzone.atwork
where nfs-server is the name of the nfs server of the install images and myzone.atwork is the name of a host at work that can access the nfs server.
Now thanks to nfs URLs I can mount the file system using:
mount localhost:6049/export/install
Automounting requires a small amount of hackery to workaround a feature of the automounter where it assumes any mount from a “local” address can be achieved using a loopback mount. So the map entry for install looks like this:
install / -fstype=xnfs 127.0.0.1:6049/export/install
Then in /usr/lib/fs/xfns I have a mount script:
#!/bin/ksh -p exec /usr/sbin/mount $@
And viola I have automounting nfs over a compressed ssh tunnel, mainly because I can! I can then live upgrade my home system over nfs via an ssh tunnel with compression to each new build as it comes out.
This also allows the pleasant side effect of being able to pause any install from the directory by using pstop(1) to stop the ssh process and prun(1) to continue it, which can be useful if I want to have better interactive perfomance over the network for a period while the upgrade continues.