-   Debian (
-   -   automount usb mass storage (

checkmate3001 08-24-2008 03:52 AM

automount usb mass storage
Hello peeps,

I've got a debian 4 (etch) system with kde. Every time I stick in a usb flashdrive it auto-mounts and asks if I want to open it or not. I have no problems with it.

However, I want to change the way it mounts so that I can use the uuid of the flash drive to assign it a static mount point (ie: always mount flashdrive with uuid=7586-3937 to /media/flashdrive1). I haven't gotten the chance to see what happens if I insert two flashdrives at once... but I think it would be random which flashdrive would mount where.

My question is: where does all this magic happen? I have no mentions of the flashdrive in my fstab. I've tried putting a line including the uuid and mount point in my fstab which leads to permission problems when I try to mount it. Another thing I find strange is that the current mount point for the flashdrive gets created on the fly when I insert the flashdrive. /media/disk does not exist when the usb flashdrive is not mounted - but it does exist when it is mounted. I always thought the directory had to exist before the usb flashdrive was mounted.

Can anyone point me in the direction of where to find where all this magic happens so I can poke around and try to configure it to my liking?


makuyl 08-24-2008 06:29 AM

This is one possibility:
plug in stick
"dmesg" look for the device, let's say it's sdc:sdc1
"udevinfo -a -p `udevinfo -q path -n /dev/sdc` | grep serial" #get the serial, for me: ATTRS{serial}=="0602101948231"
add to the top of /etc/udev/rules.d/60-persistent-storage.rules the following line:
BUS=="usb", KERNEL=="sd?1", SYSFS{serial}=="0602101948231", NAME="kingston", SYMLINK="kingston%n"
use any name, I have kingston there
add to /etc/fstab the following line:
/dev/kingston1 /media/kingston vfat noauto,users,exec,noatime,umask=000 0 0
make a dir under media:
drwxrwx--- 2 root users 4096 2008-08-24 13:15 kingston

Plenty more on google for usb and udev.

Edit: You might have to do "/etc/init.d/udev restart" before it works, can't remember.

specialized 08-24-2008 11:10 AM

udevrules dont look in the fstab file
Do a good udev rule and works fine
and remember to add the user to plugdev and messagebus.


makuyl 08-24-2008 12:27 PM

No. You can set permissions for mounting in fstab like above, but yes, you could also set them in the rule.

checkmate3001 08-24-2008 02:02 PM

Thank you guys. I found the udev stuff earlier, but I was scared - it looked deep and important. I will read a little about it and give it a try. I didn't know that was where it all happend. Good to know.

Thanks again.

checkmate3001 08-25-2008 04:49 AM

Worked like a charm. Now it always mounts where I want it. Fantastic. Makes it easier to write a backup script or something... haven't really done anything yet. But I'm happy.

All times are GMT -5. The time now is 03:36 PM.