Linux Know-How provides a collection of introductory texts on often needed Linux skills.

Can I mount automatically?

Yes, you can automatically mount a file system as you access it and unmount when you stop using it. It works similar to what you have experienced under MS Windows. Yet, if you used removable media extensively under DOS or Windows, you must have noticed that automounting is not entirely foolproof.

There are two utilities for automounting under Linux, and they are callled "supermount" and "automount".


Mandrake 7.2 gives you the option of using "supermount" as a setup option. So the simplest way to "supermount" is to install latest Mandrake and select this option. My /etc/fstab on a computer running Mandrake may contain the following lines:

/dev/hda3 / ext2 defaults 1 1

none /dev/pts devpts mode=0620 0 0

/dev/hda4 /home ext2 defaults 1 2

/mnt/cdrom /mnt/cdrom supermount fs=iso9660,dev=/dev/cdrom 0 0

/mnt/floppy /mnt/floppy supermount fs=vfat,dev=/dev/fd0 0 0

/mnt/zip /mnt/zip supermount fs=vfat,dev=/dev/zip 0 0

none /proc proc defaults 0 0

/dev/hdb2 /usr ext2 defaults 1 2

/dev/hdb5 swap swap defaults 0 0

In the example above, you may notice that I selected to supermount 3 file systems: cdrom, floppy and zipdrive. I can edit the file /etc/fstab manually (e.g. with pico) or use the supermount command to customize the supermount to my needs. Automount

To set up "automount", I first run the programs ntsysv (as root) and make sure that automount service ("autofs") is enabled.

Then, I configure automount by editing the files /etc/auto.master and /etc/auto.misc, e.g. (as root):

pico /etc/auto.master

My /etc/auto.master looks like that:

/misc /etc/auto.misc --timeout 1

This says that my automount devices will be mounted in the directory /misc (which must exist and be empty). My automount drives will automatically unmount one second after I stop using them (for example, after I exit the directory). This is a short time--you may choose a longer one. The detailed config file is /etc/auto.misc . Here is mine:

kernel -ro,soft,intr

cdrom -fstype=auto,ro :/dev/cdrom

floppy -fstype=auto,rw :/dev/fd0

zipdrive -fstype=vfat,rw :/dev/sda4

dosdrive -fstype=vfat,ro :/dev/hda1

hacker_cdrom -fstype=nfs,ro hacker:/mnt/cdrom

hacker_floppy -fstype=nfs,rw hacker:/mnt/floppy

hacker_usr -fstype=nfs,ro hacker:/usr

Each line consists of 3 space delimited fields. The first field is the "key" which will be the name of the subdirectory (under /misc) to which the device will be mounted. This directory must NOT exist. It will not be visible when I use the command ls , but I can "cd" to it and my device will then mount. Don't ask me why it is so, and how to use this automount in GUI. I don't know. The hacker stuff in my auto.misc is the cdrom and floppy from another computer in my home network.

I automount to the directory /misc (not /mnt) so that I can also mount file systems manually, without using automount, to the directory /mnt.

Last Update: 2010-12-16