Understanding auto mount in Linux

In Linux, the entire system, hardware, files application programs are constructed in a tree like structure, which we call the Linux File System. At the top of the hierarchy you find (/) root. All other items in the file system descend from /, e.g. binary executables in Linux is located in a directory called “bin” under root (/bin). Mounting, in Linux terminology, means that contents of a certain location, be it local hardware (like hard disks, CD ROMs, USB Drives etc) or in a remote machine is made available to be accessed from your Linux system. During the mounting process, these hardware devices, or file systems on remote machines are mapped onto a directory of your local Linux file system. Thus, accessing this directory technically means that you are accessing the content of your physical storage device.

When the connection between the hardware device and the local Linux file system is made, after completing whatever the data transfers/modifications the Linux system also expects you to tear that connection down. This process is called “unmounting”. Mounting and unmounting can be done manually via issuing terminal instructions or automatically via assigning it to a daemon, in which case the system will automatically recognize external file systems without the user’s intervention. The automatic mounting process is known as ‘Auto-mount’.

There are two types of auto-mounting in Linux

  • AMD
  • Autofs

How to Use AMD Automounter

AMD automounter is used especially in network file systems, in which one machine needs to access files on a remote machine over a network. Binaries and files that amd command uses are located in:

  • /usr/sbin/amd amd executable
  • /etc/amd.conf amd configuration file which can be customized to add/delete new remote file systems to be mounted on your local system
  • /etc/rc.d/init.d/amd run this to start amd
  • /.automount temporary directory to manage the mount points

The default process of automounting using AMD looks like this.

  • Start amd by typing at the terminal

/etc/rc.d/init.d/amd start

  • type

/usr/sbin/amd -a /.automount /net /etc/amd.conf

This command will automount the file systems specified in /etc/amd.conf to the mount point /net.

Additionally you may also find the following comands useful, when using amd.

  • /etc/rc.d/init.d/amd status check amd status
  • cat /etc/mtab view available mount devices
  • amq -ms check status amd status
  • df check disk free space
  • showmount -e displays a list of exported directories.
  • tail -100 /var/log/messages view log

How to Use Autofs Automounter

  • First you need to install autofs using an installation manager. You may download the autofs RPM file available at,

http://rpm.pbone.net/index.php3/stat/4/idpl/3196737/dir//com/autofs-3.1.7-8.i586.rpm.html

  • Install autofs rpm file.

rpm -qa | grep autofs

  • You will find two automount configuration files in /etc directory. One is auto.master and the other is auto.misc.
  • Assume your auto.master has an entry like this;

/misc /etc/auto.misc –timeout 60

This means that /misc directory will contain the autofs mount points, and /etc/auto.misc is where the default mount map file is located, and also after 60 seconds of idling the device will be automatically unmounted. Assume you want to automount your CD-ROM onto the Linux file system.

  • Add the following line to the end of auto.misc file.

cdrom -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

  • Save and exit from auto.misc file.
  • Restart autofs by typing the following command at the terminal.

/etc/init.d/autofs restart

  • Once autofs restarts, initially you may not be able to view the contents of the CD-ROM at /misc as configured.
  • Type at the terminal.

ll /misc/cdrom

  • You will be able to see the contents of the CD-ROM now.
  • Once you are done simply eject the CD.

Author: Nilanka

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.