Introduction
Automounting enables a system to automatically mount and unmount NFS resources wheneve they are accessed. The resource remains mounted as long as the directory is in use and if not accessed for a certain period of time the directory gets automatically unmounted.
Automounting provides the following features:
Saves boot time by not mounting resources when the system boots.
Silently mounts and unmounts resources without the need of superuser prviliege.
Reduces netwrok traffic because NFS resources are mounted only when in use.
The client side service uses the automount command, the autofs file system and automountd daemon to automatically mount file systems on demand.
Working:
The automount service svc:/system/filesystem/autofs:default reads the master map file auto_master to create the initial set of mounts at system startup. These mounts are points under which the file systems are mounted when access requests are received. After the initial mounts are made the automount command is used to update the autofs mounts as necssery.
The automount service uses the following maps to perform automounting of file systems in demand:
Master Maps:
The master map auto_master determines the location of all autofs mount points. Given below is a sample auto_master file.
root@sandbox:/# cat /etc/auto_master
#
# Copyright 2003 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)auto_master 1.8 03/04/28 SMI"
#
# Master map for automounter
#
+auto_master
/net -hosts -nosuid,nobrowse
/home auto_home -nobrowse
Direct Map:
A direct map is an automount point. In this there is a direct association between a mount point on the client and a directory on the server. Direct map entries are preceeded by /- in the auto_master file.
Indirect Map:
An indirect map uses a substitution value of a key to establish the association of a mount point on the client and a directory on the server. The auto_home is an example of an indirect map.
Demonstration:
For this demo I'll perform an automount operation for a ZFS dataset to a client.
On the server:
Create the zpool and the corresponding dataset to be shared.
root@sandbox:/# zpool create spool c2t0d0
root@sandbox:/# zfs create spool/sfs
Check value of sharenfs property
root@sandbox:/# zfs get sharenfs spool/sfs
NAME PROPERTY VALUE SOURCE
spool/sfs sharenfs off default
Add entry in /etc/dfs/dfstab file.
root@sandbox:/# grep sfs /etc/dfs/dfstab
share -F nfs -o rw -d "test share" /spool/sfs
root@sandbox:/#
Automounting enables a system to automatically mount and unmount NFS resources wheneve they are accessed. The resource remains mounted as long as the directory is in use and if not accessed for a certain period of time the directory gets automatically unmounted.
Automounting provides the following features:
Saves boot time by not mounting resources when the system boots.
Silently mounts and unmounts resources without the need of superuser prviliege.
Reduces netwrok traffic because NFS resources are mounted only when in use.
The client side service uses the automount command, the autofs file system and automountd daemon to automatically mount file systems on demand.
Working:
The automount service svc:/system/filesystem/autofs:default reads the master map file auto_master to create the initial set of mounts at system startup. These mounts are points under which the file systems are mounted when access requests are received. After the initial mounts are made the automount command is used to update the autofs mounts as necssery.
The automount service uses the following maps to perform automounting of file systems in demand:
Master Maps:
The master map auto_master determines the location of all autofs mount points. Given below is a sample auto_master file.
root@sandbox:/# cat /etc/auto_master
#
# Copyright 2003 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)auto_master 1.8 03/04/28 SMI"
#
# Master map for automounter
#
+auto_master
/net -hosts -nosuid,nobrowse
/home auto_home -nobrowse
A direct map is an automount point. In this there is a direct association between a mount point on the client and a directory on the server. Direct map entries are preceeded by /- in the auto_master file.
Indirect Map:
An indirect map uses a substitution value of a key to establish the association of a mount point on the client and a directory on the server. The auto_home is an example of an indirect map.
Demonstration:
For this demo I'll perform an automount operation for a ZFS dataset to a client.
On the server:
Create the zpool and the corresponding dataset to be shared.
root@sandbox:/# zpool create spool c2t0d0
root@sandbox:/# zfs create spool/sfs
root@sandbox:/# zfs get sharenfs spool/sfs
NAME PROPERTY VALUE SOURCE
spool/sfs sharenfs off default
Turn on the sharenfs property and verify that it's on.
root@sandbox:/# zfs set sharenfs=on spool/sfs
root@sandbox:/# zfs get sharenfs spool/sfs
NAME PROPERTY VALUE SOURCE
spool/sfs sharenfs on local
root@sandbox:/# grep sfs /etc/dfs/dfstab
share -F nfs -o rw -d "test share" /spool/sfs
root@sandbox:/#
Use the share command to activate the nfs shares.
root@sandbox:/# share
- /spool/sfs rw ""
Verify that the share is active.
root@sandbox:/# showmount -e sandbox
export list for sandbox:
/spool/sfs (everyone)
On the client:
Check that the automount service is running.
root@trick:/# ps -ef | grep -w automountd
root 528 527 0 13:48:16 ? 0:00 /usr/lib/autofs/automountd
root 527 1 0 13:48:16 ? 0:00 /usr/lib/autofs/automountd
root@trick:/# svcs -a | grep -w autofs
online 14:04:34 svc:/system/filesystem/autofs:default
Create directory to use as automount mount pont.
root@trick:/# mkdir /auto
I'll be using a direct map named auto_test for the purpose of this demonstration. Now I'll add it's entry in /etc/auot_master file.
root@trick:/# grep test /etc/auto_master
/- auto_test -nosuid
Create the auto_test direct map file in /etc
root@trick:/# cat /etc/auto_test
/auto -rw,nosuid sandbox:/spool/sfs
Run automount -v to refresh the maps.
root@trick:/# automount -v
automount: /auto mounted
automount: no unmounts
Check if /auto gets automatically mounted when accessed.
root@trick:/# date
Tue Jun 27 15:14:51 IST 2017
root@trick:/# df -h /auto/
Filesystem size used avail capacity Mounted on
auto_test 0K 0K 0K 0% /auto
root@trick:/# cd /auto/
root@trick:/auto# df -h .
Filesystem size used avail capacity Mounted on
sandbox:/spool/sfs 976M 21K 976M 1% /auto
root@trick:/auto# date
Tue Jun 27 15:15:09 IST 2017
root@trick:/auto# df -h /auto/
Filesystem size used avail capacity Mounted on
sandbox:/spool/sfs 976M 21K 976M 1% /auto
superb ..great work Sahil Bhai..Congrat..
ReplyDeleteThank you
Delete