Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Goal

  • 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)

Question

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

Current Attempt

/etc/auto.master:

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

/etc/auto.ext-usb:

/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

1 Answer 1

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.

Example:

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 at 12:18

Your Answer

 
discard

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.