# autofs, hotplug, supermount, what to use? automount usbstick

## ArloWhite

I've scoured the net looking for a way to automount a usbstick.  I've encountered all of these different possibilities:

1. Using hotplug

2. Using autofs

3. Using supermount in /etc/fstab

4. Using a custom script that follows events

I found a few solutions but they seemed to be pretty questionable.  Is there no official method for this?  I encountered problems with each of these solutions.  For example, on the supermount discussion, it was mentioned that supermount is dangerous because it doesn't unmount before you remove the stick.  There was also talk of setting a timeout somehow.

I'd really like to hear an official solution for this.  What does Redhat and other distros do when you pop in a cd / usbstick and it's automatically mounted??

Thanks,

Arlo

----------

## richk449

First you decide to run linux, the OS which has no official organization at all.

Then you decide to run Gentoo, the distro which is designed to give the user the maximum choice and not force him/her to do anything in a particular way.

Then you ask for the official method to mount a usbstick.

On a more helpful note, every method you mentioned (and any method that could be conceived of) will have the unmounting/corruption problem you mentioned.  Even Windows has it.  If you pull the stick out while it is being written to, you will have problems. 

I would just pick the method that sounds easiest to you.  If you just have one usbstick, and it will always be the only usb device you use, just make a custom script that you can run to mount it and set the permissions correctly.  That will save you alot of trouble.

----------

## ArloWhite

Point taken.  I probably worded that in  the wrong way.

What I meant by official was the "right/best" way, or the way most people agree to accomplish this.  I've just been frustrated trying to figure out this thing and I was looking for a comparison of the methods.  For example, it was mentioned that supermount is somewhat contriversal and diagreed upon.  It isn't included in mm-sources, but is in gentoo-dev-sources.  This to me signals that some people have decided against this method.

I really should just go do the research and write a automount how-to.  It just seems to me that this problem hasn't been solved effectively yet.

-Arlo

----------

## taskara

I have never used anything auto mounting, I always manually mount my devices, however I think SUPERMOUNT might be what you're after.

Perhaps this will help you.

Also Redhat / SuSE etc use supermount I think.

I know under SuSE you insert a cd/dvd/blankcd and it pops up asking what you want to do with it (like windows xp). And if you plug in a USB stick or external hdd, it is auto detected, auto setup and mounted for you.

So it's definitely possible.. how, I have no idea

----------

## Hypnos

There is also submount, which is I use for my USB filesystems

----------

## GenKreton

You could (if you use udev) set up a custom rule for it and a symlink and put that in fstab. Then its a simple command to mount and umount, the same every time regardless AND its safe.

----------

## taskara

 *GenKreton wrote:*   

> You could (if you use udev) set up a custom rule for it and a symlink and put that in fstab. Then its a simple command to mount and umount, the same every time regardless AND its safe.

 

this interests me.. could you explain further?

----------

## wpoely86

 *taskara wrote:*   

>  *GenKreton wrote:*   You could (if you use udev) set up a custom rule for it and a symlink and put that in fstab. Then its a simple command to mount and umount, the same every time regardless AND its safe. 
> 
> this interests me.. could you explain further?

 

Just install udev and put a rule in /etc/udev/rules.d/1-usbstick.rules like:

```

BUS="usb", SYSFS_serial="<SERIAL>", NAME="%k", SYMLINK="usbstick"

```

This creates an symlink called /dev/usbstick that points to your usbstick.

And then you put the following in /etc/fstab:

```

/dev/usbstick   /mnt/usbstick vfat  rw,user 0 0

```

Now you can mount and umount your usbstick with:

mount /mnt/usbstick and umount /mnt/usbstick

----------

## taskara

oh ok, so it's not actually auto, but u get the benefit of udev whereby it assigns certain devices based on serial number etc..

----------

## GenKreton

 *taskara wrote:*   

> oh ok, so it's not actually auto, but u get the benefit of udev whereby it assigns certain devices based on serial number etc..

 

Its not automatic but now you can easily associate with a dockapp button, gdesklets, karamba, gkrellm or whatever your fancy is. And you will never pull it out during a write.

----------

## taskara

cool..

I'm setting up gentoo on my friend's new laptop, and he's new to linux - I'm almost done, but I'd like to get supermount working for him.

I have to use mm-sources due to bad dsdt table on Dell X300 - anyone know if there's a supermount patch for mm-sources?

----------

