Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


  • I have a USB drive -- let's say the drive's ID is /dev/disk/by-id/thediskid
  • I would like to mount the drive -- by ID -- to a folder (let's call it /MOUNT_FOLDER)


  • What is the best way to do this using autofs?

Current Attempt


/localam auto.linux
/[another mount]  [auto.othermount] --timeout=5 -- ghost
/MOUNT_FOLDER auto.ext-usb --timeout=5
/ -


/MOUNT_FOLDER /dev/disk/by-id/thediskid

I know I'm missing something but I can't seem to get a good lead on what the proper syntax is.

New to Linux; appreciate a pass if I'm overlooking something simple. Thanks!

share|improve this question
Is this the only usb-drive you ever want to mount, or do you want to do something more generic? – Nils Jul 3 '12 at 19:35
up vote 1 down vote accepted

In your constellation /MOUNT_FOLDER is the base directory where subdirectories will be mounted by the indirect mount-map auto.ext-usb.

See man 5 autofs for further details.


usbdisk -fstype=vfat,uid=yourworkingusername :/dev/disk/by-id/thediskid

If you cd /MOUNT_FOLDER/usbdisk your usbdisk will be mounted there (I assume it is vfat formatted).

You can use /etc/fstab instead - but then you will to have to mount "by hand".

The entry in /etc/fstab looks like this:

/dev/disk/by-id/thediskid /MOUNT_FOLDER vfat defaults,user,noauto 0 0

After that you can mount the USB-Disk as ordinary user with mount /MOUNT_FOLDER.

share|improve this answer
Nils, not sure I follow you completely, though what you're saying sounds possible. In this case, how would you recommend accomplishing mounting the contents of the USB disk into the /MOUNT_FOLDER location? Also, am I using the wrong tool in autofs (is it recommended that I just use /etc/fstab instead, for example?) – SeanKilleen Jul 3 '12 at 20:23
@goober if you want to use the automounter-mechanism using indirect maps is the "recommended" way. If you really want to use the main directory as mountpoint you can define your entry directly in the direct map auto.master - but changes in auto.master will only be activated by restarting autofs (as opposed to indirect maps). I'll update my answer about /etc/fstab – Nils Jul 4 '12 at 11:11
I'm not attempting to argue your solution that it's the recommended way. My issue is that I'm getting the syntax wrong. In order to mount a usb drive by id using autofs, could you show me the proper way to configure the files given the information I've provided initially? I understand the concept generally when it's explained but implementing your suggestions seems to be going wrong somewhere. – SeanKilleen Jul 4 '12 at 19:44
@goober I tried this myselv and updated my answer. – Nils Jul 4 '12 at 20:47
@SeanKilleen The problem with indirect maps is that you will have to use a subdirectory. There are two ways around this: a) use a direct map b) use a soft-link /MOUNT_FOLDER that points to /MOUNT_FOLDER/usbdisk. – Nils Apr 1 '14 at 12:18
  1. add to /etc/auto.master

    /var/autofs/removable   /etc/auto.removable     --timeout=2
  2. add to /etc/auto.removable

    theDiskLabel         -fstype=ext4,rw,gid=1000,umask=002       :/dev/disk/by-uuid/thediskid
  3. restart autofs service

    sudo service autofs restart
  4. Access your directory, thats it!

    cd /var/autofs/removable/theDiskLabel
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.