Self units in Linux.

Autofs daemon can automatically mount and unmount filesystems local and remote, freeing them manually using the mount and umount.

Autofs behaves the user as follows:

There are directories that are associated with file systems. When the user executes a warrant referred to the contents of that directory, autofs automagically mounted file system corresponding to that mount point.

Upon completion of the transaction, expected some time before it automatically removed.

Autofs is a solution that consists of a party that is included in the core system (which is responsible for detecting that we are entering a directory of self) and one in user space (a devil) to handle assembly itself.

By that I mean that the kernel must have been compiled with support for it if we use it. The good news is that autofs is completely modular and in the case (unlikely) that your kernel does not support, we will not have to rebuild it entirely, but only compiling autofs module (saving time and a reboot).

If we have an old kernel (pre 2.0.x) or not we are interested in walking recompiling can hitting solutions amd (automounter daemon), but less efficient operating only in user space. This daemon is obsolete in Linux, although I think the BSD people are still in use: -?.

To check whether we have support for him in the kernel can do:

     $ Cat / proc / filesystems

This shows a list of file systems supported by our kernel. If you see a line such that:

     nodev autofs

It is true that our kernel.

Once verified, we must install the devil. On RedHat and the like, the devil and a basic set an example and the script that defines the self-service are in the package autofs-*. i386.rpm.

To install:

     # Rpm-ivh autofs-*. i386.rpm

Rpm automatically add the service to current runlevel but not yet started (and is not desirable that we do now, because we have not yet set).

Important: the installation packages that include distributions are safe (or should be), but if optáis to download updated versions of the Internet, you should always check which files are included, the signature of the package (unless the summary fits MD5 as expected) and the scripts that will launch during the rpm installation.

Remember that when you install packages, we do it as root with all the dangers involved.

To check the signature (PGP / GPG and MD5):

     $ Rpm - checksig autofs-*. i386.rpm

To check the scripts for installation and removal operations for malignant:

     $ Rpm-q - scripts autofs-*. i386.rpm

Other measures such as making simulations chroot installation can be excessive, although saying: "a good administrator, the administrator is paranoid." So there each with their conscience :-).

Once installed, go to the settings. Let us assume, for simplicity, the user only has a floppy drive and a cdrom. We saltaremos zip drives, jaz, nfs volumes, netbios, etc..

RedHat autofs package, in versions that I manage, create a directory:

/ misc

Bring configuration files:

/ etc / auto.master
/ etc / auto.misc

And the self-service:

/ etc / rc.d / init.d / autofs

For the configuration we are going to do, the directory misc <over us, so:

     # Rm-r / misc

Edit / etc / auto.master to leave like this:

     Auto.master # $ Id $
     / mnt / auto.floppy / etc / auto.montaje.floppy - timeout 3
     / mnt / auto.cdrom / etc / auto.montaje.cdrom - timeout 15
     # # #

The "timeout" is the time in seconds pass demon leave after we have finished working with the floppy or cdrom before dismantling. You can adjust it to your liking if you see that it is too big or small

Auto.montaje.cdrom and auto.montaje.floppy files do not exist, and taking that as a template to create examples that show in / etc / auto.misc or the man page autofs (5):

     # $ Id $ auto.montaje.cdrom
     cdrom-fstype = iso9660, user, noexec, ro: / dev / cdrom
     # # # # $ Id $ auto.montaje.floppy floppy-fstype = auto, user, noexec, rw, uid = 0, gid = 19: / dev/fd0 # # #

The "fstype" are to be passed to the mount by the devil.

We can set specific options for certain filesystems (In the example of floppy uid and gid = 0 = 19 of the systems themselves are fat, vfat, msdos, etc.) to be ignored in a transparent manner if the file system is different (if The floppy is ext2 mount not complain because the devil of self happens uid and gid).

This configuration is not exactly the safest in the world, but is quite comfortable. The gid = 19 should belong to the group "floppy", which should belong to users who wish to write to floppy disks.

In many environments, allowing assembly of units (and writing them in case the floppy) to users is considered a security issue, but only if we have physical access to the machine that should not worry too much.

Written configuration files now go to the directory / mnt and proceed as follows:

Delete directories cdrom and floppy if any:

     # Rm-r floppy cdrom

Auto.cdrom and create directories auto.floppy.

     # Mkdir auto.floppy auto.cdrom

We create two soft links, through which access to the file system of self:

     # Ln-s / mnt / auto.cdrom / cdrom / mnt / cdrom
     # Ln-s / mnt / auto.floppy / floppy / mnt / floppy

Note that neither / mnt / auto.cdrom / cdrom or / mnt / auto.floppy / floppy exists, and we must not under any circumstances create.

The demon of self-will build these directories every time you need to access a disk and destroy them when we stop using it.

We should not touch anything that has inside / mnt / auto.cdrom / and / mnt / auto.floppy.

At this point, we have a comment (add a "#" at the beginning) the lines for cdrom and floppy in / etc / fstab and start the service so that we can enjoy the self:

     # / Etc / rc.d / init.d / autofs start.