AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only

Using AutoFS to automatically mount an SMB file system

By Mohammed Hashmath Hussain posted 2 days ago

  

The AutoFS extension automatically and transparently mounts file systems whenever a file or a directory within that file system is accessed. Like NFS, AutoFS can be used to automatically mount SMB shares. There are two methods to do this:
1. Direct map
2. Indirect map


Make sure the automountd is active

# lssrc -s automountd
Subsystem         Group            PID          Status
 automountd       autofs           6947288      active

If automountd is not active, refer this link to start it.


1. Direct map

a. Set up the /etc/auto_master file with the special key (/-) and map file.

# cat /etc/auto_master
/-    /home/auto.direct


b. Set up the map file in following format.

# cat /home/auto.direct
/testdir    -fstype=smbc,wrkgrp=SMB_30.DEV    llm138.in.ibm.com/testuser/<secure_password>:/testshare

To avoid specifying <secure_password> in the map file, use mksmbcred command which encrypts the password and stores the credentials in /etc/smbcred. Refer this link for mksmbcred command.

In this case the map file should be in following format.

# cat /home/auto.direct
/testdir    -fstype=smbc,wrkgrp=SMB_30.DEV    llm138.in.ibm.com/testuser:/testshare


c. Run automount command which sets up the autofs mount

# automount

# mount
  node       mounted        mounted over    vfs       date        options
-------- ---------------  ---------------  ------ ------------ ---------------
         /dev/hd4         /                jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd2         /usr             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd9var      /var             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd3         /tmp             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd1         /home            jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd11admin   /admin           jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /proc            /proc            procfs Jun 23 18:37 rw
         /dev/hd10opt     /opt             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/livedump    /var/adm/ras/livedump jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /ahafs           /aha             ahafs  Jun 23 18:38 rw
         /home/auto.direct /testdir         autofs Jun 25 01:11 ignore


d. Now if you access the directory '/testdir', SMB share is automatically mounted.

# cd /testdir

# mount
  node       mounted        mounted over    vfs       date        options
-------- ---------------  ---------------  ------ ------------ ---------------
         /dev/hd4         /                jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd2         /usr             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd9var      /var             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd3         /tmp             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd1         /home            jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd11admin   /admin           jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /proc            /proc            procfs Jun 23 18:37 rw
         /dev/hd10opt     /opt             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/livedump    /var/adm/ras/livedump jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /ahafs           /aha             ahafs  Jun 23 18:38 rw
         /home/auto.direct /testdir         autofs Jun 25 01:14 ignore
llm138.in.ibm.com /testshare       /testdir         smbc   Jun 25 01:18 wrkgrp=SMB_30.DEV


2. Indirect map

a. Set up the /etc/auto_master file with a directory as key and map file.

# cat /etc/auto_master
/autodir    /home/auto.indirect


b. Set up the map file in following format.

# cat /home/auto.indirect
mount1    -fstype=smbc,wrkgrp=SMB_30.DEV    llm138.in.ibm.com/testuser/<secure_password>:/testshare

To avoid specifying <secure_password> in the map file, use mksmbcred command.


c. Run automount command which sets up the autofs mount.

# automount

# mount
  node       mounted        mounted over    vfs       date        options
-------- ---------------  ---------------  ------ ------------ ---------------
         /dev/hd4         /                jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd2         /usr             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd9var      /var             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd3         /tmp             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd1         /home            jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd11admin   /admin           jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /proc            /proc            procfs Jun 23 18:37 rw
         /dev/hd10opt     /opt             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/livedump    /var/adm/ras/livedump jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /ahafs           /aha             ahafs  Jun 23 18:38 rw
         /home/auto.indirect /autodir         autofs Jun 25 01:25 ignore


d. Now if you access the directory "/autodir/mount1", SMB share is automatically mounted.

# cd /autodir/mount1

# mount
  node       mounted        mounted over    vfs       date        options
-------- ---------------  ---------------  ------ ------------ ---------------
         /dev/hd4         /                jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd2         /usr             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd9var      /var             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd3         /tmp             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd1         /home            jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/hd11admin   /admin           jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /proc            /proc            procfs Jun 23 18:37 rw
         /dev/hd10opt     /opt             jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /dev/livedump    /var/adm/ras/livedump jfs2   Jun 23 18:37 rw,log=/dev/hd8
         /ahafs           /aha             ahafs  Jun 23 18:38 rw
         /home/auto.indirect /autodir         autofs Jun 25 01:25 ignore
llm138.in.ibm.com /testshare       /autodir/mount1  smbc   Jun 25 01:26 wrkgrp=SMB_30.DEV


Note: If <secure_password> is not specified in the map file and no credentials are setup with mksmbcred command, the automount will fail.


For more information about automount subsystem, checkout this link.

0 comments
19 views

Permalink