Managing NFS with Autofs

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Managing NFS with Autofs"

Transcription

1 Managing NFS with Autofs Brent Callaghan Sun Microsystems, Inc. Page 1 of 28

2 What s Coming... Some history Direct Maps Indirect Maps Master Map Executable Maps Map Sources Offset Mounts Mount Options Multiple Mounts Replica Servers Map Variables Key Substitution Auto-unmounting Autofs Mounts Visible Directories and finally some Recommendations Page 2 of 28

3 In the beginning - The Automounter No kernel changes - loopback NFS Open /foo App /tmp_mnt/foo Mounts foo NFS Client Automountd (NFS Server) Lookup foo User Kernel (symlink) Page 3 of 28

4 Enter Autofs A kernel filesystem Eliminates symbolic link Open /foo App Mounts foo Autofs Automountd Lookup foo User Kernel Page 4 of 28

5 Automounter Maps Map a name to a location Name Location blorf fratzl glolb... rtzblf:/export/fnarg nord:/export/frib zygorf:/export/snitz Page 5 of 28

6 Direct Maps Directly map autofs mountpoints to locations (not very scalable) Autofs Mountpoints Locations /blorf /usr/fratzl /opt/glolb... rtzblf:/export/fnarg nord:/export/frib zygorf:/export/snitz Page 6 of 28

7 Indirect Maps Map autofs directory entries to locations (hugely scalable) /home Autofs mountpoint alan jane peter... rtzblf:/export/alan nord:/export/jane zygorf:/export/peter Page 7 of 28

8 Master Map Establishes initial autofs mountpoints Autofs mountpoint Map name Default mount options /blorf auto_blorf /home auto_home -noquota /- auto_direct +auto_local Page 8 of 28

9 Executable Maps Generate locations on the fly godzilla #!/bin/sh SERVER=$1 dfshares -h $1 awk {print $1 \t $SERVER : $1 \\ } sort Executable program or script godzilla:/export/shares Page 9 of 28

10 Executable Maps (cont) Useful for: Map sources that are not directly accessible by automounter. Implementing policy based on client, time of day, location, etc. Highly dynamic location data. Page 10 of 28

11 Map Sources Maps managed in local files or in a variety of name services. NIS NIS+ Files Automounter LDAP Page 11 of 28

12 Offset Mounts Trigger Directory /net (autofs) NFS Mountpoint /kinky /usr /local /bin kinky /usr/local/bin kinky:/usr/local/bin Offset path Page 12 of 28

13 Offset Mounts (cont) Offsets useful for constructing a mounted namespace on10 \ /archives stub:/export/archives \ /Codemgr_wsdata stub:/export/gate/codemgr_wsdata \ /deleted-files stub:/export/gate/deleted-files \ /packages stub:/export/packages \ /proto stub:/export/gate/proto \ /public stub:/export/gate/public \ /usr stub:/export/gate/usr Offset paths Page 13 of 28

14 Mount Options (optional) Map entries can have mount options for each mount that override the map default. bandersnatch -ro,noquota frumious:/jabber But keep them to a minimum! Use mount defaults or map defaults Page 14 of 28

15 Multiple Mounts A single map entry can initiate multiple mounts key offset location { offset location }... on10 \ /archives stub:/export/archives \ /Codemgr_wsdata stub:/export/gate/codemgr_wsdata \ /deleted-files stub:/export/gate/deleted-files \ /packages stub:/export/packages \ /proto stub:/export/gate/proto \ /public stub:/export/gate/public \ /usr stub:/export/gate/usr Page 15 of 28

16 Replica Servers A map entry can have multiple locations if the location is replicated. key location {location }... pkg pkg pkg server1:/pkg server2:/pkg server3:/pkg server1,server2,server3:/pkg server1,server2(1),server3(2):/pkg Weighting reduces preference Page 16 of 28

17 Replica Servers (cont) Replica list ordered by: My host Same server My subnet (subject to weighting) My network (subject to weighting) Solaris mounts entire list if read-only Otherwise, mount the best Page 17 of 28

18 Map Variables Select a mount based on a client characteristic /usr/local/bin server1,server2:/export/local/$osname using map variable text in exported path share /export/local/linux share /export/local/solaris share /export/local/macosx share /export/local/netbsd share /export/local/hpux Page 18 of 28

19 Map Variables (cont) Most useful map variables are predefined Variable Meaning Derived From $ARCH Architecture type uname -m I86pc $CPU Processor type uname -p I386 $HOST Hostname uname -n dinky Example $OSNAME Operating system name uname -s solaris $OSREL Operating system release uname -r 5.7 $OSVERS Operating system version uname -v Generic & Insert key text Entry key Page 19 of 28

20 Key Substitution The map key often reappears in the location arnold homeserve:/export/home/& brian homeserve:/export/home/& charles homeserve:/export/home/& jane tinytots:/export/home/& kim tinytots:/export/home/& oscar homeserve:/export/home/& rumplestiltskin tinytots:/export/home/& Page 20 of 28

21 Auto-unmounting Without auto-unmounting, mounts would pile up Every 5 min, automountd attempts to unmount Multiple mounts are unmounted in a bottom-up fashion. Page 21 of 28

22 Autofs Mounts Map entries default to NFS, but other filesystems can be mounted, incl autofs! src -fstype=autofs auto_src Mount option Location is map name Can use a hierarchy of autofs mounts to build a flexible, hierarchical namespace. Page 22 of 28

23 Autofs Mounts (cont) Namespace using autofs hierarchy /shared auto_master auto_shared auto_shared home local pkgs src -fstype=autofs auto_home aa,bb,cc:/export/local/$arch -fstype=autofs auto_pkgs -fstype=autofs auto_src auto_home arnold homeserve:/export/home/& brian homeserve:/export/home/& charles homeserve:/export/home/& jane tinytots:/export/home/& kim tinytots:/export/home/& oscar homeserve:/export/home/& rumplestiltskin tinytots:/export/home/& Page 23 of 28

24 Visible Directories Automounter directories used to show only mounted filesystems To avoid mount storms Page 24 of 28

25 Visible Directories (cont) Solaris 2.6 provided fully visible directories via delayed mounts. Includes a -nobrowse option for huge directories, e.g. /home /net Page 25 of 28

26 Recommendations Keep it simple! Avoid the use of mount options, map variables, multiple mounts, etc unless they provide real value. Not all automounters are equal. Some cannot handle fancy map technology. Avoid maps in files Yields non-uniform namespace Difficult to distribute, maintain Page 26 of 28

27 Recommendations (cont) Avoid direct maps use indirect maps. Plan your namespace don t put everything in one map! Test your automounter implementation at Connectathon. Page 27 of 28

28 Page 28 of 28