AuToFS

autofs, also called automounter or automount, allows you to connect storage media like a USB disk and have it mounted automatically. For example, if you have two USB disks, and you want to have one mounted as usb-120gb and the other as usb-80gb as soon as you plug them in, this is possible with autofs.

= QuickStart = This example assumes you want to plug in a USB disk and have it mounted on /misc/usb. Just Find Out Your Distribution and proceed accordingly.

Ubuntu
This article shows you how to configure autofs so that a USB disk that you attach automatically gets mounted to /misc/usb. Install autofs: sudo apt-get install autofs

Find out your USB disk's UUID: hwinfo --block [...]  Device Files: /dev/sdc1, /dev/disk/by-id/usb-Myson_Century,_Inc._USB_Mass_Stor age_Device_100-part1, /dev/disk/by-path/pci-0000:00:1d.7-usb-0:3:1.0-scsi-0:0:0: 0-part1, /dev/disk/by-uuid/84ff6790-9b69-4401-9ba2-43d044af1d30, /dev/disk/by-la bel/DATALUX

Configure autofs
Have a file /etc/auto.master like this: /misc  /etc/auto.misc --timeout=60 --ghost

This will create all mount points beneath /misc. The mount points will appear even if they are not active ("ghosts").

Create a file /etc/auto.misc like this: usb      -fstype=auto            UUID="84ff6790-9b69-4401-9ba2-43d044af1d30"

Start autofs
/etc/init.d/autofs start

Now you can find your USB disk automatically mounted to /misc/usb.

TroubleShooting

 * You can find log entries from automounter NOT in dmesg but in /var/log/messages.
 * If your device is already mounted, automount may not mount it again. This means you will also have to stop other automounters like gnome-volume-manager.

SuSE 10.3
hwinfo --block [...]  Device Files: /dev/sdc1, /dev/disk/by-id/usb-Myson_Century,_Inc._USB_Mass_Stor age_Device_100-part1, /dev/disk/by-path/pci-0000:00:1d.7-usb-0:3:1.0-scsi-0:0:0: 0-part1, /dev/disk/by-uuid/84ff6790-9b69-4401-9ba2-43d044af1d30, /dev/disk/by-la bel/DATALUX /misc  /etc/auto.misc +auto.master usb            -fstype=auto            :/dev/disk/by-uuid/84ff6790-9b69-4401-9ba2-43d044af1d30 /etc/init.d/autofs start
 * Find out your USB disk's UUID:
 * Have a file /etc/auto.master:
 * Have a file /etc/auto.misc:
 * Start your automounter:

Now, as soon as you plug in your USB disk you will find its content under /misc/usb. If you want this setting to be persistent after booting, run the command: chkconfig autofs on

= See also =
 * http://gentoo-wiki.com/HOWTO_Auto_mount_filesystems_(AUTOFS)