Skip to content

A tunnel to my automounter

September 29, 2004

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 nfs://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 nfs://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.

Advertisements

From → bsc, Sun

3 Comments
  1. Chris,Simply brilliant. On thing though, the mount above suggests I don’t need a mount point, yet I have to specify one:

    # mount nfs://localhost:6049/export/install
    mount: Mount point cannot be determined
    # mount nfs://localhost:6049/export/install /mnt
    # df -h /mnt
    Filesystem             size   used  avail capacity  Mounted on
    nfs://localhost:6049/export/install
    1007G   935G    63G    94%    /mnt
    
  2. Stacey, you are right you need a mount point for mounting!

  3. Peter Schow permalink

    Very nice. Just a reminder to any readers that you need to have AllowTcpForwarding set to “yes” in your /etc/ssh/sshd_config, for this to work

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: