« HOWTO Handcraft network configurationsHOWTO install NFS on Fedora »

HOWTO Setup autofs on Fedora

20/11/10

HOWTO Setup autofs on Fedora

With autofs, the file systems are mounted as required or on demand, and then automatically unmounted when they have not been used for some time. This means you can have two machines both of which mount file systems from the other and the order you boot them does not
matter as long as the remote system is not required during the boot.

Before we begin you will need a machine that is exporting some shares over NFS so see my HOWTO install NFS on Fedora page for getting that setup first. I'll wait. :)

So now you know how to setup NFS and get some directories shared.

Installing the software on Fedora is as easy as any other with yum.

sudo yum install autofs

That will also install a number of configuration files into /etc and one in /etc/sysconfig.

To set up a the automounts for the NFS shares being exported by a server we need to edit the file /etc/auto.master adding one line. Using the shares from a machine called linux32. we will be mounting them locally in /net/linux32/

with a 10 minute (600 second) time out.
sudo nano /etc/auto.master
/etc/auto.master
/net/linux32              /etc/auto.nfslinux32       --timeout=600

The file in the middle does not exist, yet, we are about to create it.

sudo nano /etc/auto.nfslinux32
/etc/auto.nfslinux32
home       -fstype=nfs,rsize=32768,wsize=32768,intr,tcp,noatime   linux32:/home

You will need a line similar to the one above for each share from linux32. The magic of automounting is that you do not need to create all the local mount point directories yourself. they will be created and deleted as necessary. The entry in auto.master will create the first two directories /net and /net/linux32.

To explain the layout of auto.nfslinux32. The first parameter is the mount point on the local machine. In this case home which means you will access the fs via /net/linux32/home. The next parameter -fstype gives the mounting options note it is an fs type of 'nfs'.
The remaining options are from mount and fstab. Take a look at the man pages you may not want to use these.

Make sure that the autofs service will startup at boot time. If not set it so it will.

sudo chkconfig --list autofs
autofs          0:off 1:off 2:on 3:on 4:on 5:on 6:off
sudo chkconfig  autofs on

Start, stop and reload the files for autofs without rebooting using the usual service command.

sudo service autofs status
sudo service autofs stop
sudo service autofs start
sudo service autofs restart
sudo service autofs reload

Very similar automounting will be done automatically when the mount point starts with /net. I found there were a few annoyances using the automatic configuration so I do the above.

You may like to turn on the browse mode. This does have one downside in that it means that the auto mounts will be mounted each time you access the root directory where they are mounted.

Edit the file /etc/sysconfig/autofs changing the BROWSE_MODE flag to "yes" and reloading autofs

/etc/sysconfig/autofs
sudo nano /etc/sysconfig/autofs
sudo service autofs reload

Further reading

  1. Man pages for autofs, auto.master, mount, umount, nfs
  2. The mount & umount commands, how to mount stuff and it's options and get it unmounted again.
  3. /etc/fstab how to mount file systems automatically at boot time
  4. a href="http://blogging.dragon.org.uk/index.php/mini-howtos/howto-install-nfs-of-fedora">HOWTO install NFS on Fedora
  5. /etc/hosts file IP lookups
  6. /etc/hosts.allow and /etc/hosts.deny A bit of security
  7. Setting up Samba/Cifs

No feedback yet

Here are a collection of Mini-HOWTOs some of which are too short even for that grand title. I keep them around as it is easier to remember where to look these up that to remember the content of the mini-HOWTO

Search

Contents

multiblog platform